socket.io icon indicating copy to clipboard operation
socket.io copied to clipboard

http-polling timeout question

Open dymsza opened this issue 15 years ago • 7 comments

Hey,

Is this correct:

 this.pollTimeout = setTimeout(function () {
      self.packet({ type: 'noop' });
      self.log.debug(self.name + ' closed due to exceeded duration');
    }, this.manager.get('polling duration') * 1000);

there is not self.end(reasone) like in case of other transports, i'm asking this question because i have problem with hanging connections and this look like potential reason.

dymsza avatar Sep 23 '11 21:09 dymsza

You don't want to end the socket, you want to end the response. Also look at the impl of #packet.

On Fri, Sep 23, 2011 at 2:38 PM, dymsza < [email protected]>wrote:

Hey,

Is this correct:

 this.pollTimeout = setTimeout(function () {
     self.packet({ type: 'noop' });
     self.log.debug(self.name + ' closed due to exceeded duration');
   }, this.manager.get('polling duration') * 1000);

there is not self.end(reasone) like in case of other transports, i'm asking this question because i have problem with hanging connections and this look like potential reason.

Reply to this email directly or view it on GitHub: https://github.com/LearnBoost/socket.io/issues/536

Guillermo Rauch LearnBoost CTO http://devthought.com

rauchg avatar Sep 23 '11 21:09 rauchg

ok i got it.

So other question, we call onSocketClose when socket connection is dropped(example browser window close)

But what if someone close browser between polls ? Each poll is new connection ?

And also:

is there any other reasons for removing heartbeat timeouts for polling then traffic/performance ? if not can you add configuration for this ?

dymsza avatar Sep 23 '11 22:09 dymsza

  • If someone closes the browser between polls, the subsequent poll would be a fresh new session at the protocol level
  • Yes, since we expect a request every seconds, that's our heartbeat. The only problem of this is that it wouldn't match the heartbeat set globally (or rather, you have to actively make the polling duration and heartbeats match), but it's much better for performance
  • I could, but can you elaborate on the need ?

rauchg avatar Sep 23 '11 22:09 rauchg

No sound like there is no need.

I have ascending linear number of connections and try to attach any point and i'm looking blindly :/

dymsza avatar Sep 23 '11 22:09 dymsza

Keep in mind, a browser will open a number of sockets through which requests will be multiplexed. A Socket.IO long-polling request can go through any of those. If socket.io captures a request through that socket, since that socket is capable of emitting other requests, some of which are potentially not mean for socket.io, that socket won't be closed by Socket.IO, and it'll be subject to the normal Keep-Alive timeout flow.

In other words, a long polling connection might signify a number of sockets greater than 2 being used throughout the life of the socket.io session.

rauchg avatar Sep 23 '11 22:09 rauchg

I've seen some people try to match open TCP sockets with Socket.IO sessions count and being surprised, hence the explanation.

rauchg avatar Sep 23 '11 22:09 rauchg

I was a little bit not precise. i said Connection by I had in mind Socket.IO Clients.

So during the time with server runs the number of clients is ascending linear and with that CPU use is also ascending linear.

Only clue with i have is that large number of connections is very old.

So i checked this clue and did hack in garbageCollection with disconnect clients older then 24h and it helped so something need to be wrong.

Maybe you have idea what could I check ?

dymsza avatar Sep 23 '11 23:09 dymsza