moped
moped copied to clipboard
TCP Keepalive Support
I've ported TCP Keepalive support from the redis-rb client. Quite often firewalls exist between the mongo client and the server. These firewalls aren't always configured to perform a proper fin/ack sequence when closing idle connections. This causes moped and other TCP based client to simply hang on the next request until the underlying operating system determines the connection has been closed.
Linux has support for TCP keepalives on sockets. My implementation ensures that the appropriate methods are only created if supported by the platform. If not supported, an alternate method is created with a simple log statement to let the user know Keepalives won't be available on that platform. Conditional method creation ensures performance by not having to check for the constants on every connection calls.
I'd like to give this code back to mongoid/moped to help make the socket connections more resilient.
Does moped provide any of the alternatives mentioned here to handle timeouts in idle connections?
@ElMassimo Moped doesn't implement keep alive for like the article recommend, which is what my merge enables. Moped also to my knowledge doesn't support MaxIdleConnectionTimeout and has no connection reaping like the C# driver.