Le 06/01/2013 18:14, Tomasz Sterna a écrit :
Dnia 2013-01-04, pią o godzinie 14:31 +0100, Sylvain Guglielmi pisze:
At first, we had to face "ghost connections" (from users not properly
disconnecting). To solve that, I changed c2s.xml to have
   <check>
       <interval>600</interval>
       <idle>0</idle>
       <keepalive>600</keepalive>
     </check>
So "unplugged" connections will be closed correctly after 10min. It
solved the problem.
....
My problem is that I still can see the 500 established connections
(netstat -n | grep 'XXX.XXX.XXX.XXX'). Even if this "connection spam"
occurred yesterday (long enough for <keepalive> to do its job)
Are you sure this is a problem with jabberd, not your TCP stack
configuration?

It's usually the job of TCP layer to detect and close torn-down
connections and using user level protocol layer keepalives to enforce
this is just for convenience to the users, so they won't write to the
vacuum (instead just one whitespace gets lost).

If you are on Linux take a look at:
https://www.linux.com/learn/docs/ldp/768-tcp-keepalive-howto
http://www.speedguide.net/articles/linux-tweaking-121


It seems that my TCP stack is configured to send keepalive probes after 2h (default linux timers : 7200s / 75s / 9probes).

If I understand correctly the link you sent (https://www.linux.com/learn/docs/ldp/768-tcp-keepalive-howto), the system-wide keepalive parameters are not used (*) unless "setsockopt" is called after socket creation (in this case, I guess it's the "accept" call in "mio_impl.h[150] : _mio_accept(...)"). Adding the following code at "mio_impl.h[168]" may be a way to test if it solves things :

    optval = 1;
if(setsockopt(newfd, SOL_SOCKET, SO_KEEPALIVE, &optval, sizeof(optval)) < 0)
    {
        close(newfd);
        return;
    }

Unfortunately, I've not yet managed to get a proper dev environement for jabberd2 (coding under Windows does not help, I guess -_-'... But I got most of the libs working : I'm probably not that far from making it work). Due to deadlines, I'm not sure I'll be able to do it before the end of January. I'll keep you updated as soon as I've managed to run some tests. If this solves the issue, maybe it can be envisioned to add an option for that in c2s.xml. It seems that "setsockopt" can also set keepalive probes timers to override system-wide config. It could probably be added to c2s.xml too, to complete or supersede the "keepalive by sending space" thing.

(*) : I've had a hard time to find the default value for the "SO_KEEPALIVE" option. On windows, it seem to be false [http://msdn.microsoft.com/en-us/library/windows/desktop/ee470551%28v=vs.85%29.aspx] , but I'm not yet sure about the default value on Linux... Also, I've not yet found any way to force system-wide use of keepalive for TCP streams.

--
Sylvain "Gugli" Guglielmi
Gamedev@Nadeo@Ubisoft



Reply via email to