robertklep / nefit-easy-http-server

HTTP server to access Nefit/Bosch XMPP backend over HTTP
MIT License
38 stars 15 forks source link

The /bridge/ endpoints work but the /api/ ones do not #8

Closed pyrocumulus closed 6 years ago

pyrocumulus commented 7 years ago

Just installed this package through a docker image. The package works well as long as I use the /bridge/ endpoints. However when I try the /api/ endpoints I get the following result on every call, whatever endpoint I choose:

curl http://myserver:3000/api/status
Cannot GET /api/status

The resulting HTTP status code appears to be a 404 if I'm correct. I set the environment variable DEBUG to nefit-easy-core but that doesn't appear to give me more information. Any idea what's going wrong or how I can further test it?

robertklep commented 7 years ago

That's strange, especially since requests to /bridge do work.

You could set DEBUG to * to enable logged in all parts of the server (including Express, which handles the HTTP request routing). Perhaps that might provide a clue what's going on.

pyrocumulus commented 7 years ago

That's what I thought as well. Setting DEBUG to * does provide more information, but nothing remarkable about the /api calls. This is the output:

express:router dispatching GET /api/status +48s
express:router query  : /api/status +4ms
express:router expressInit  : /api/status +1ms
express:router <anonymous>  : /api/status +2ms
express:router logger  : /api/status +4ms
express:router jsonParser  : /api/status +4ms
body-parser:json skip empty body +0ms
express:router trim prefix (/api) from url /apistatus +3ms
express:router router /api : /api/status +0ms
express:router dispatching GET /status +1ms
express:router <anonymous>  : /api/status +3ms
finalhandler default 404 +1ms
morgan log request +0ms
172.17.0.1 - - [25/Nov/2017:18:16:05 +0000] "GET /api/status HTTP/1.1" 404 23 "-" "Mozilla user agent stuff"

On the other hand, the /bridge call does a lot more stuff after the dispatching after trim prefix. nefit-easy-core does not appear to get hit at all according to this log. Does that mean anything to you?

robertklep commented 7 years ago

The finalhandler default 404 suggests that the "status" command can't be found in nefit-easy-commands (which is used to dispatch the higher-level commands). I have no idea how that could happen, but it does explain why you're getting the 404's.

Can you try installing the package locally (not inside a Docker container) and see if it works?

FWIW, I assume that trim prefix (/api) from url /apistatus is a typo? It should read trim prefix (/api) from url /api/status (forward slash between "api" and "status")

pyrocumulus commented 7 years ago

Sure, haven't done node stuff before but I think I can manage and see what happens. Will try soon.

That other thing was a typo indeed, logger from docker didn't want me to copy paste the log contents to I had to do it the old way ;-)

pyrocumulus commented 6 years ago

Took me long enough, but I finally managed to run easy-server locally (from source) to check if I'd have the same problem. But then it works just as advertised. This means that the cause lies within that Docker image and (fully) within nefit-easy-http-server.

Next step I'll try and see if I can reproduce this problem in a brand new Docker image (if I can build such a thing).

pyrocumulus commented 6 years ago

This was solved. Was a problem in the docker image.

robertklep commented 6 years ago

Thanks for the update 👍🏻