ebin123456 / py-amqplib

Automatically exported from code.google.com/p/py-amqplib
GNU Lesser General Public License v2.1
0 stars 0 forks source link

Support TCP Keepalive #32

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Which version of amqplib are you using?
0.6.1

Have you checked to see if there is a newer version in the "Featured
Downloads" section of the front page of this project?
Yes

Which broker are you using (RabbitMQ?) which version?
RabbitMQ 1.7.2 with some custom patches

Which version of Python?
2.7

What steps will reproduce the problem?
1. Have a client on Windows XP connect to a RabbitMQ broker via a ssh tunnel 
from another host.
2. Let the client sit idle for around a day eventually

What is the expected output? What do you see instead?
Eventually, the RabbitMQ (Linux) side will not see the connection anymore. 
However, the Windows end would still assume it is connected.

Even netstat on the Windows end shows the connection as ESTABLISHED. This is 
true even when the ssh tunnel itself has been taken down.

Please provide any additional information below.
Although the problem might be due to the FIN/RST packets being lost somewhere, 
enabling TCP keepalives seems to be an effective workaround.
It would involve adding the following to _AbstractTransport.__init__(), right 
after the socket is created:

        self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)

I'll be happy to submit this as a proper patch if required.

Original issue reported on code.google.com by g...@theoldmonk.net on 8 Jun 2011 at 1:51

GoogleCodeExporter commented 9 years ago
OK, I guess that seems reasonable, in as revision 8d15d34db22e

If anyone has a problem with this, it could be made optional.  Not sure if the 
default would be the new (keepalive enabled) or old (keepalive disabled) 
behaviours.

Original comment by barry.pe...@gmail.com on 23 Jun 2011 at 1:28