urbica / galton

Lightweight Node.js isochrone map server
https://galton.urbica.co
MIT License
271 stars 36 forks source link

Empty reply from server #195

Closed robert-pm closed 6 years ago

robert-pm commented 6 years ago

Hi all - I am trying to get galton running using the instructions to run the server from docker:

docker run -d -p 4000:4000 urbica/galton "https://s3.amazonaws.com/metro-extracts.mapzen.com/moscow_russia.osm.pbf" car

After the docker image has started, running:

curl http://localhost:4000 --get --data 'lng=37.62&lat=55.75'

gives:

curl: (52) Empty reply from server

Checking docker logs on my container gives the following:

PM2 | Starting execution sequence in -cluster mode- for app name:index id:0 PM2 | App name:index id:0 online 0|index | 🚀 ON AIR @ :::4000 0|index | Error: Can't set headers after they are sent. 0|index | at validateHeader (_http_outgoing.js:494:11) 0|index | at ServerResponse.setHeader (_http_outgoing.js:501:3) 0|index | at Server. (/usr/src/app/src/index.js:25:11) 0|index | at emitTwo (events.js:126:13) 0|index | at Server.emit (events.js:214:7) 0|index | at parserOnIncoming (_http_server.js:602:12) 0|index | at HTTPParser.parserOnHeadersComplete (_http_common.js:116:23) PM2 | App name:index id:0 disconnected PM2 | App [index] with id [0] and pid [104], exited with code [0] via signal [SIGINT]

Any insight/help would be great. Thanks, Robert

robert-pm commented 6 years ago

This looks to be a result of the if statement on line 24 of src/index.js. It looks like this if statement needs to be moved above the res.writeHead statement so you don't end up trying to updated the headers after they have been written.

stepankuzmin commented 6 years ago

Thanks for the report, @robert-pm! Should be fixed in next latest release.