API URL: field is left empty in the Tyk dashboard


#1

I configured Tyk, following https://tyk.io/docs/tyk-api-gateway-v-2-0/installation-options-setup/install-tyk-pro-edition-on-ubuntu/ on Ubuntu 14.04 LTS 64 bit

Then I successfully logged in, and attempting to create a simple API, using “Add new API” option.

It showed, “API URL: (Please save this API to see the URL)”
However, after I filled all the data, this field is left empty.

What could have gone wrong?

sudo tail -f /var/log/upstart/tyk-dashboard.log indicates the below:

[May 12 21:36:46] INFO Sending notification{ApiUpdated 693302bc26884e2a4e92b5eed28aa2be}
ERROR 2016/05/12 21:36:46.462367 panic_handler.go:26: PANIC
URL: /api/apis/57352d0d5ee8574ac8000003/url
ERROR: Invalid input to ObjectIdHex: “”
STACK:
goroutine 258 [running]:
github.com/gocraft/web.(*Router).handlePanic(0xc82035a000, 0xc8200c4e40, 0xc8200c4e60, 0xa60f80, 0xc82016cf30)
/home/tyk/go/src/github.com/gocraft/web/router_serve.go:251 +0x34e
github.com/gocraft/web.(*Router).ServeHTTP.func1(0xc82035a000, 0xc8200c4e40)
/home/tyk/go/src/github.com/gocraft/web/router_serve.go:43 +0x68
panic(0xa60f80, 0xc82016cf30)
/usr/local/go/src/runtime/panic.go:426 +0x4e9
gopkg.in/mgo.v2/bson.ObjectIdHex(0x0, 0x0, 0x0, 0x0)
/home/tyk/go/src/gopkg.in/mgo.v2/bson/bson.go:175 +0x210
main.(*OrganisationDocument).GetById(0xc8200c4f00, 0x0, 0x0, 0xc8202ef100)
/home/tyk/go/src/github.com/lonelycode/tyk-analytics/ModelApiRegister.go:116 +0x8e
main.(*APIContext).GetAPIUrl(0xc820178188, 0x7fa69dc053b0, 0xc8200c4e40, 0xc8200c4e60)
/home/tyk/go/src/github.com/lonelycode/tyk-analytics/ApiApiManagement.go:191 +0x1ca
reflect.Value.call(0xaf26a0, 0xde5f08, 0x13, 0xc70d58, 0x4, 0xc820140ab8, 0x3, 0x3, 0x0, 0x0, …)
/usr/local/go/src/reflect/value.go:435 +0x120d
reflect.Value.Call(0xaf26a0, 0xde5f08, 0x13, 0xc820140ab8, 0x3, 0x3, 0x0, 0x0, 0x0)
/usr/local/go/src/reflect/value.go:303 +0xb1
github.com/gocraft/web.middlewareStack.func1(0x7fa69dc053b0, 0xc8200c4e40, 0xc8200c4e60)
/home/tyk/go/src/github.com/gocraft/web/router_serve.go:113 +0xad4
main.(*APIContext).ApiAuthorisationRequired(0xc820178188, 0x7fa69dc053b0, 0xc8200c4e40, 0xc8200c4e60, 0xc820253780)
/home/tyk/go/src/github.com/lonelycode/tyk-analytics/Main.go:425 +0x37b
reflect.Value.call(0xb2e1a0, 0xde5e38, 0x13, 0xc70d58, 0x4, 0xc820141050, 0x4, 0x4, 0x0, 0x0, …)
/usr/local/go/src/reflect/value.go:435 +0x120d
reflect.Value.Call(0xb2e1a0, 0xde5e38, 0x13, 0xc820141050, 0x4, 0x4, 0x0, 0x0, 0x0)
/usr/local/go/src/reflect/value.go:303 +0xb1
github.com/gocraft/web.(*middlewareHandler).invoke(0xc82035ca80, 0xc6d840, 0xc820178188, 0x16, 0x7fa69dc053b0, 0xc8200c4e40, 0xc8200c4e60, 0xc820253780)
/home/tyk/go/src/github.com/gocraft/web/router_serve.go:133 +0x286
github.com/gocraft/web.middlewareStack.func1(0x7fa69dc053b0, 0xc8200c4e40, 0xc8200c4e60)
/home/tyk/go/src/github.com/gocraft/web/router_serve.go:122 +0x1a5
github.com/gocraft/web.StaticMiddlewareFromDir.func1(0x7fa69dc053b0, 0xc8200c4e40, 0xc8200c4e60, 0xc820253780)
/home/tyk/go/src/github.com/gocraft/web/static_middleware.go:30 +0x16e
github.com/gocraft/web.(*middlewareHandler).invoke(0xc82035c210, 0xc2b200, 0xc820178180, 0x16, 0x7fa69dc053b0, 0xc8200c4e40, 0xc8200c4e60, 0xc820253780)
/home/tyk/go/src/github.com/gocraft/web/router_serve.go:131 +0x6e
github.com/gocraft/web.middlewareStack.func1(0x7fa69dc053b0, 0xc8200c4e40, 0xc8200c4e60)
/home/tyk/go/src/github.com/gocraft/web/router_serve.go:122 +0x1a5
github.com/gocraft/web.StaticMiddlewareFromDir.func1(0x7fa69dc053b0, 0xc8200c4e40, 0xc8200c4e60, 0xc820253780)
/home/tyk/go/src/github.com/gocraft/web/static_middleware.go:30 +0x16e
github.com/gocraft/web.(*middlewareHandler).invoke(0xc82035c1e0, 0xc2b200, 0xc820178180, 0x16, 0x7fa69dc053b0, 0xc8200c4e40, 0xc8200c4e60, 0xc820253780)
/home/tyk/go/src/github.com/gocraft/web/router_serve.go:131 +0x6e
github.com/gocraft/web.middlewareStack.func1(0x7fa69dc053b0, 0xc8200c4e40, 0xc8200c4e60)
/home/tyk/go/src/github.com/gocraft/web/router_serve.go:122 +0x1a5
github.com/gocraft/web.(*Router).ServeHTTP(0xc82035a000, 0x7fa69dc05350, 0xc82017fba0, 0xc820243340)
/home/tyk/go/src/github.com/gocraft/web/router_serve.go:48 +0x355
net/http.(*ServeMux).ServeHTTP(0xc820351e60, 0x7fa69dc05350, 0xc82017fba0, 0xc820243340)
/usr/local/go/src/net/http/server.go:1910 +0x17d
net/http.serverHandler.ServeHTTP(0xc8203cc080, 0x7fa69dc05350, 0xc82017fba0, 0xc820243340)
/usr/local/go/src/net/http/server.go:2081 +0x19e
net/http.(*conn).serve(0xc8203bc800)
/usr/local/go/src/net/http/server.go:1472 +0xf2e
created by net/http.(*Server).Serve
/usr/local/go/src/net/http/server.go:2137 +0x44e

Please let me know what is going wrong.
Thank you.


Can't access gateway or portal -- domain/hostname issues?
#2

its trying to get your ORG ID and can’t, are you sure your bootstrap was correct? Have you changed anything?

Are you running as a super user instead of an organisation based user?


#3

Thanks Martin for your quick reply.

I just changed the domain names to either 127.0.0.1 or localhost in the setting up.

See my commands below:

sudo /opt/tyk-gateway/install/setup.sh --dashboard=http://127.0.0.1:3000 --listenport=8080 --redishost=localhost --redisport=6379 --domain=""

sudo /opt/tyk-dashboard/install/setup.sh --listenport=3000 --redishost=localhost --redisport=6379 --mongo=mongodb://127.0.0.1/tyk_analytics --tyk_api_hostname=http://localhost --tyk_node_hostname=http://localhost --tyk_node_port=8080 --portal_root=/portal --domain=“127.0.0.1”

sudo /opt/tyk-pump/install/setup.sh --redishost=localhost --redisport=6379 --mongo=mongodb://127.0.0.1/tyk_analytics

sudo service tyk-pump start
sudo service tyk-dashboard start

sudo service tyk-dashboard restart
sudo service tyk-gateway start

sudo /opt/tyk-dashboard/install/bootstrap.sh 127.0.0.1

I am logged in as the super user that was created at the set up time:

Login at http://127.0.0.1:3000/
User: [email protected]
Pass: test123

This is a basic configuration with single/stand-alone/local Redis, single/stand-alone/local Mongo instances.

I tried the hybrid version and it worked well. Just the local installation is not working.

There are many features not working (failing with the same error log) as well. For example, I am unable to add access rule in http://127.0.0.1:3000/#/portal/policies/add

I must be missing some trivial thing. Any help or hint is highly appreciated, as we are currently evaluating Tyk for our research in my university.

Regards,
Pradeeban.


#4

Yeah that won’t work, seriously, use a real domain or at least a hostname (that isn’t localhost), even if it’s a host hack on your local machine

It’s because your bootstrap didn’t work properly and the domain settings are all messed up. You really should be using hostnames for the dashboard

My suggestion:

A. Go to hosts file and add:

127.0.0.1 dashboard.tyk-local.com
127.0.0.1 portal.tyk-local.com

(do this on any host that needs to interact with this machine)

B. Stop Everything

sudo service tyk-pump stop
sudo service tyk-gateway stop
sudo service tyk-dashboard stop

C. Run the setup scripts again:

sudo /opt/tyk-gateway/install/setup.sh --dashboard=http://dashboard.tyk-local.com:3000 --listenport=8080 --redishost=localhost --redisport=6379 --domain=""

sudo /opt/tyk-dashboard/install/setup.sh --listenport=3000 --redishost=localhost --redisport=6379 --mongo=mongodb://127.0.0.1/tyk_analytics --tyk_api_hostname=127.0.0.1 --tyk_node_hostname=http://127.0.0.1 --tyk_node_port=8080 --portal_root=/portal --domain="dashboard.tyk-local.com"

Notice how I have fixed these, you were using an http:// as the hostname param, it should just be the hostname (no protocol), hence the $HOSTNAME var in the tutorial

D. Bootstrap, again:

sudo service tyk-pump start
sudo service tyk-dashboard start
sudo service tyk-gateway start
sudo /opt/tyk-dashboard/install/bootstrap.sh 127.0.0.1

That should set things up properly so features should work.


#5

Thanks a lot for pointing out the mistake, Martin.
I followed your fixed commands.

I can ping to
dashboard.tyk-local.com
portal.tyk-local.com

I also configured Tyk Pump
sudo /opt/tyk-pump/install/setup.sh --redishost=localhost --redisport=6379 --mongo=mongodb://127.0.0.1/tyk_analytics

Now,
http://127.0.0.1:3000/ gives
404 page not found

sudo tail -f /var/log/upstart/tyk-gateway.log gives the below continuously:

[May 13 08:06:35] ERROR Failed to register node, retrying in 5s

and,

sudo tail -f /var/log/upstart/tyk-dashboard.log gives
[May 13 08:06:35] ERROR No nodes available

Any hint where did I mess up this time?

In fact, I experienced this behaviour earlier as well. But when I moved to localhost (instead of dashboard.tyk-local.com,
portal.tyk-local.com, …), it appeared to work (of course, with the original issues I report). So it could still something to do with the configuration of hosts in the /etc/hosts file (?).


#6

Lol, you just set the dashboard URL in the setup command to dashboard.tyk-local.com, so it won’t be on http://127.0.0.1:3000/, it will be: http://dashboard.tyk-local.com:3000 :wink:

Domain handling is a bit odd in Tyk: it’s extremely strict.

This is a different problem - the gateway is trying to register with the dashboard, and the dashboard says your license is depleted and so is bouncing it. That will fix itself, because we ran the setup again, your license won;t be registered anymore, so you’ll need to add it again before starting the gateway service.


#7

Thanks. :smiley:

Now I run
sudo /opt/tyk-dashboard/install/bootstrap.sh dashboard.tyk-local.com

and
http://dashboard.tyk-local.com:3000/ takes me to the correct dashboard, and all is well so far.

But, my initial problem persists. :’(

That means, API URL field is left empty in the Tyk dashboard.

API Designer API URL: (Please save this API to see the URL)

I give,
API Name: mynewapi
Custom Domain: portal.tyk-local.com
[Others left as they are, as they are correctly populated].

I save it now.
API URL is still left blank.

The log indicates the below (the same as before):

[May 13 08:38:07] INFO Sending notification{ApiUpdated 22d9ec13fb9749a45b318ec802de4f7f}
ERROR 2016/05/13 08:38:10.603099 panic_handler.go:26: PANIC
URL: /api/apis/5735caaf5ee8577f1a000004/url
ERROR: Invalid input to ObjectIdHex: “”
STACK:
goroutine 180 [running]:
github.com/gocraft/web.(*Router).handlePanic(0xc8202d60b0, 0xc820a12600, 0xc820a12620, 0xa60f80, 0xc8204b6bb0)
/home/tyk/go/src/github.com/gocraft/web/router_serve.go:251 +0x34e
github.com/gocraft/web.(*Router).ServeHTTP.func1(0xc8202d60b0, 0xc820a12600)
/home/tyk/go/src/github.com/gocraft/web/router_serve.go:43 +0x68
panic(0xa60f80, 0xc8204b6bb0)
/usr/local/go/src/runtime/panic.go:426 +0x4e9
gopkg.in/mgo.v2/bson.ObjectIdHex(0x0, 0x0, 0x0, 0x0)
/home/tyk/go/src/gopkg.in/mgo.v2/bson/bson.go:175 +0x210
main.(*OrganisationDocument).GetById(0xc8200c4480, 0x0, 0x0, 0xc820356800)
/home/tyk/go/src/github.com/lonelycode/tyk-analytics/ModelApiRegister.go:116 +0x8e
main.(*APIContext).GetAPIUrl(0xc820a74180, 0x7fd3c4f53340, 0xc820a12600, 0xc820a12620)
/home/tyk/go/src/github.com/lonelycode/tyk-analytics/ApiApiManagement.go:191 +0x1ca
reflect.Value.call(0xaf26a0, 0xde5f08, 0x13, 0xc70d58, 0x4, 0xc82019caa8, 0x3, 0x3, 0x0, 0x0, …)
/usr/local/go/src/reflect/value.go:435 +0x120d
reflect.Value.Call(0xaf26a0, 0xde5f08, 0x13, 0xc82019caa8, 0x3, 0x3, 0x0, 0x0, 0x0)
/usr/local/go/src/reflect/value.go:303 +0xb1
github.com/gocraft/web.middlewareStack.func1(0x7fd3c4f53340, 0xc820a12600, 0xc820a12620)
/home/tyk/go/src/github.com/gocraft/web/router_serve.go:113 +0xad4
main.(*APIContext).ApiAuthorisationRequired(0xc820a74180, 0x7fd3c4f53340, 0xc820a12600, 0xc820a12620, 0xc820492e10)
/home/tyk/go/src/github.com/lonelycode/tyk-analytics/Main.go:425 +0x37b
reflect.Value.call(0xb2e1a0, 0xde5e38, 0x13, 0xc70d58, 0x4, 0xc82019d040, 0x4, 0x4, 0x0, 0x0, …)
/usr/local/go/src/reflect/value.go:435 +0x120d
reflect.Value.Call(0xb2e1a0, 0xde5e38, 0x13, 0xc82019d040, 0x4, 0x4, 0x0, 0x0, 0x0)
/usr/local/go/src/reflect/value.go:303 +0xb1
github.com/gocraft/web.(*middlewareHandler).invoke(0xc8202f7dd0, 0xc6d840, 0xc820a74180, 0x16, 0x7fd3c4f53340, 0xc820a12600, 0xc820a12620, 0xc820492e10)
/home/tyk/go/src/github.com/gocraft/web/router_serve.go:133 +0x286
github.com/gocraft/web.middlewareStack.func1(0x7fd3c4f53340, 0xc820a12600, 0xc820a12620)
/home/tyk/go/src/github.com/gocraft/web/router_serve.go:122 +0x1a5
github.com/gocraft/web.StaticMiddlewareFromDir.func1(0x7fd3c4f53340, 0xc820a12600, 0xc820a12620, 0xc820492e10)
/home/tyk/go/src/github.com/gocraft/web/static_middleware.go:30 +0x16e
github.com/gocraft/web.(*middlewareHandler).invoke(0xc8202f7560, 0xc2b200, 0xc820a74178, 0x16, 0x7fd3c4f53340, 0xc820a12600, 0xc820a12620, 0xc820492e10)
/home/tyk/go/src/github.com/gocraft/web/router_serve.go:131 +0x6e
github.com/gocraft/web.middlewareStack.func1(0x7fd3c4f53340, 0xc820a12600, 0xc820a12620)
/home/tyk/go/src/github.com/gocraft/web/router_serve.go:122 +0x1a5
github.com/gocraft/web.StaticMiddlewareFromDir.func1(0x7fd3c4f53340, 0xc820a12600, 0xc820a12620, 0xc820492e10)
/home/tyk/go/src/github.com/gocraft/web/static_middleware.go:30 +0x16e
github.com/gocraft/web.(*middlewareHandler).invoke(0xc8202f7530, 0xc2b200, 0xc820a74178, 0x16, 0x7fd3c4f53340, 0xc820a12600, 0xc820a12620, 0xc820492e10)
/home/tyk/go/src/github.com/gocraft/web/router_serve.go:131 +0x6e
github.com/gocraft/web.middlewareStack.func1(0x7fd3c4f53340, 0xc820a12600, 0xc820a12620)
/home/tyk/go/src/github.com/gocraft/web/router_serve.go:122 +0x1a5
github.com/gocraft/web.(*Router).ServeHTTP(0xc8202d60b0, 0x7fd3c4f532e0, 0xc8202660d0, 0xc820a8d340)
/home/tyk/go/src/github.com/gocraft/web/router_serve.go:48 +0x355
net/http.(*ServeMux).ServeHTTP(0xc8202f71d0, 0x7fd3c4f532e0, 0xc8202660d0, 0xc820a8d340)
/usr/local/go/src/net/http/server.go:1910 +0x17d
net/http.serverHandler.ServeHTTP(0xc820248100, 0x7fd3c4f532e0, 0xc8202660d0, 0xc820a8d340)
/usr/local/go/src/net/http/server.go:2081 +0x19e
net/http.(*conn).serve(0xc820270a80)
/usr/local/go/src/net/http/server.go:1472 +0xf2e
created by net/http.(*Server).Serve
/usr/local/go/src/net/http/server.go:2137 +0x44e

Did I miss something?


#8

Ok, it’s still the bootstrap.

Did the bootstrap script give any other output except the user and pass? If so, can you please share?

In the meantime, we’ll generate you a user manually:

~> cd /opt/tyk-dashboard/
~> ./tyk-dashboard --conf=tyk_analytics.conf --neworg --newuser

You will get this, fill in the fields, do not use spaces:

[May 13 08:59:53]  INFO Using tyk_analytics.conf for configuration
[May 13 08:59:54]  INFO Creating new Redis connection pool
[May 13 08:59:54]  INFO Creating new Redis connection pool
[May 13 08:59:54]  INFO Creating a new org...


Organisation name:      TestOrg
Organisation slug:      TestSlug
New organisation ID: <new-id-will-appear-here>

[May 13 09:01:24]  INFO Creating a new user...


First name:     John
Last name:      Smith
Email address:  [email protected]

Organisations:
--------------
0. TestOrg

Select user organisation (-1 for empty - only recommended for custom integrations):     0
New password:   test
Re-enter password:      test

Now log in with [email protected] and pw: test

If you still get the issue, then something extra weird is going on.

On a different note:

^^ This is the wrong thing to do, this domain was meant to be reserved for your developer portal (eventually), you also haven’t set up your system for custom domains in Tyk Gateway yet, so lets just start with setting up the basic API from the tutorial :slight_smile:


#9

I followed your suggestion, and the tutorial: https://tyk.io/docs/tyk-dashboard-v1-0/tutorials/set-up-your-first-api/

When I try to give access rights to the key I created, it gives the message:
Attempted access to non-owned key

In the terminal below logs are printed:
[May 13 09:39:16] ERROR API Request failed!
{“status”:“error”,“message”:“Key not found”}
[May 13 09:39:16] ERROR 45
[May 13 09:39:16] ERROR Key detail request failed
[May 13 09:39:16] WARN Key retrieval failed
[May 13 09:39:16] ERROR Attempted access to non-owned key


Now, giving you more logs from the initial problem (API URL left empty), in case if that can be useful:

[email protected]:/home/pradeeban# sudo /opt/tyk-dashboard/install/bootstrap.sh dashboard.tyk-local.com
Creating Organisation
Traceback (most recent call last):
File “”, line 1, in
File “/usr/lib/python2.7/json/init.py”, line 290, in load
**kw)
File “/usr/lib/python2.7/json/init.py”, line 338, in loads
return _default_decoder.decode(s)
File “/usr/lib/python2.7/json/decoder.py”, line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File “/usr/lib/python2.7/json/decoder.py”, line 384, in raw_decode
raise ValueError(“No JSON object could be decoded”)
ValueError: No JSON object could be decoded
ORGID:
Adding new user
Traceback (most recent call last):
File “”, line 1, in
File “/usr/lib/python2.7/json/init.py”, line 290, in load
**kw)
File “/usr/lib/python2.7/json/init.py”, line 338, in loads
return _default_decoder.decode(s)
File “/usr/lib/python2.7/json/decoder.py”, line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File “/usr/lib/python2.7/json/decoder.py”, line 384, in raw_decode
raise ValueError(“No JSON object could be decoded”)
ValueError: No JSON object could be decoded
USER AUTH:
Traceback (most recent call last):
File “”, line 1, in
File “/usr/lib/python2.7/json/init.py”, line 290, in load
**kw)
File “/usr/lib/python2.7/json/init.py”, line 338, in loads
return _default_decoder.decode(s)
File “/usr/lib/python2.7/json/decoder.py”, line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File “/usr/lib/python2.7/json/decoder.py”, line 384, in raw_decode
raise ValueError(“No JSON object could be decoded”)
ValueError: No JSON object could be decoded
NEW ID:
Setting password
curl: /usr/local/lib/libldap_r-2.4.so.2: no version information available (required by /usr/lib/x86_64-linux-gnu/libcurl.so.4)
curl: /usr/local/lib/liblber-2.4.so.2: no version information available (required by /usr/lib/x86_64-linux-gnu/libcurl.so.4)

DONE

Login at http://dashboard.tyk-local.com:3000/
User: [email protected]
Pass: test123

[email protected]:/opt/tyk-dashboard# ./tyk-dashboard --conf=tyk_analytics.conf --neworg --newuser
bash: ./tyk-dashboard: No such file or directory

I guess you meant,
[email protected]:/opt/tyk-dashboard# ./tyk-analytics --conf=tyk_analytics.conf --neworg --newuser

Also,
^[email protected]:~$ sudo tail -f /var/log/upstart/tyk-pump.log
[May 13 08:27:43] WARN redis: Connection dropped, connecting…
[May 13 08:27:43] WARN redis: Connection dropped, connecting…

Just two times when starting. So I guess after 2 attempts the connection was successful, as I can see the Tyk entries inside Redis.

Apart from these, I do not see anything else fishy in the logs.


#10

Right, so looking at the bootstrap output, it is full of errors. So the bootstrap failed, and it showed many errors that implied that something was wrong, so we could have saved a lot of time if we had just started with that.

Every other error after that, using those credentials, is irrelevant, because your setup was borked :smiley:

It looks like the failure was with your version of curl - the error is right there in the output:

As for your new problem, I have to assume that:

  1. You created the new user and organisation via the method I suggested
  2. and you didn’t add the user to an existing org
  3. you successfully created an API.

Could you confirm this?

This is fine, it’s a warning, not an error, and our redis connector does this.

Did you apply a policy to this key and then use the key?

If you did, then you need to manage access rights via the policy, not via the key edit screen (this is a bug we’ve fixed in the nightlies).

If you didn’t, then we’re down the rabbit hole.


#11

Any hint on how to rectify this? Or should I just ignore this for now, and proceed what we are doing so far?

Yes, I confirm.

Thanks for this hint. It worked.

Thanks a lot for all your help on getting this resolved. I am going to continue working on this, probably over a cluster. Will create a new thread if I encounter other issues.


#12

Not sure, you could try to update curl on your box, or install the libcurl-dev dependencies, but I’m not well versed in that codebase so not sure what to do, mind you googling the error will probably yield results :slight_smile:

Looks like you’re set up though, which is good :slight_smile:


#13

Yes, it did. Actually. :slight_smile:

Thank you.