Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Long connections and silent termination gets tabcmd stuck #304

Open
audriusrudalevicius opened this issue Aug 8, 2024 · 0 comments
Open

Comments

@audriusrudalevicius
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant