tabcmd
tabcmd copied to clipboard
Long connections and silent termination gets tabcmd stuck
We faced network issue when waiting for PDF to download/generate (takes 5-10min), because TCP connection waiting too long and no packets being sent in TCP. In our case connection is terminated without RST meaning tabcmd gets stuck in waiting for pdf download forever, unfortunately this behaviour is out of our control in our case.
One way to avoid such problem would be enable KEEP_ALIVE on the socket in client side, example:
import requests
import socket
class HTTPAdapterWithSocketOptions(requests.adapters.HTTPAdapter):
def __init__(self, *args, **kwargs):
self.socket_options = kwargs.pop("socket_options", None)
super(HTTPAdapterWithSocketOptions, self).__init__(*args, **kwargs)
def init_poolmanager(self, *args, **kwargs):
if self.socket_options is not None:
kwargs["socket_options"] = self.socket_options
super(HTTPAdapterWithSocketOptions, self).init_poolmanager(*args, **kwargs)
adapter_with_options = HTTPAdapterWithSocketOptions(socket_options=[(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)])
session = requests.Session()
session.mount(adapter_with_options)
I there possibility to add such option or any suggestion how we can avoid this problem?