Re: [Cppcms-users] Simple long polling application has memory leaks (sockets left in CLOSE_WAIT sta
Brought to you by:
artyom-beilis
From: Artyom B. <art...@gm...> - 2016-01-15 16:36:35
|
The problem is that detecting that the connection isn't alive isn't reliable. Especially when working via webserver and fastcgi/scgi. You always need to have timeouts on connections especially long-polling ones. For example if you know that client resubmits request every 10 seconds (also I'd suggest to increase it) put your own 10 seconds timeout as well as you know that the client will disconnect so why to keep one alive. Always manage timeouts on asynchronous requests. Artyo > > The problem arises in an ajax function called "listen()", which makes an > ajax POST request to the server and waits until the server has responded > or 10 seconds have passed, at which point it will fire up another "long- > polling" request. However, each of these requests remains open in the > case that they time out, and then the lighttpd server refuses any more > connections after too many requests have been issued. I'm not sure what > I'm doing wrong with my long-polling approach, but for some reason, > these sockets are not getting closed and I've been unable to determine > why after 2 days of investigating. > > |