Ubuntu + Nodejs + curl: (52) Empty reply from server

Ubuntu + Nodejs + curl: (52) Empty reply from server



I have a nodejs process listening a port on my server:


app.get('/statistic', function(req, res)
log_get_connection(req);

getStatistic().then(statistic =>
res.json(statistic);
);

);



When I try to access it via curl being on the same machine:


curl "http://127.0.0.1:<PORT>/statistic"
# or
curl "http://<EXT_IP>:<PORT>/statistic"



I get:


* Empty reply from server
* Connection #0 to host EXT_IP left intact

curl: (52) Empty reply from server



But when I access it via curl from another server I see a successful HTTP response.



I don't override res. Also if I put console.log(statistic) before res.json(statistic), I see that statistic is correct.


res


console.log(statistic)


res.json(statistic)


statistic



What's even more interesting - this setup worked perfectly fine for some time...



UPD: ufw is disabled.





have you tried restarting the server?
– user158
Aug 22 at 14:15





Do you can run curl with -v parameter (for verbose). And what happens when you try on the root route?
– Lucas Costa
Aug 22 at 14:19


-v





@user158 no, it's very undesirable
– zzomrot
Aug 22 at 14:20





@zzomrot why is that? aren't you in a testing environment? I said so because you have said that things worked fine previously.
– user158
Aug 22 at 14:29





What version of node are you running? What happens when you try using res.json() outside of the promise scope? If node is using the same or later version of V8 that Chrome 32 uses then promises are likely natively supported.
– dcd018
Aug 22 at 14:37



res.json()




1 Answer
1



Sorry, i find error - in the nodejs code there is a part which parses a file. The file has expanded and the execution of the method takes a long time.



Apparently, it so coincided that when I made a request from a third-party server, the method managed to work out and return data, and when asked from the server itself did not have time.



I found an error when the server stopped returning the result to a third-party server and console.log(statistic) before res.json(statistic) stopped working.


console.log(statistic)


res.json(statistic)



Thank you for your replies!






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)