Persistent Plugin Questions #78
Replies: 1 comment 2 replies
-
Can you post here an example of what the code looks like? I think what mean by "connection" is what httpx calls the "session". If so, you shouldn't need to discard it, a
If the PERSISTENT = HTTPX.plugin(:persistent) If the variable is going out of scope, then
This is what I would recommend. That "must reauthenticate on reconnect" requirement may be an impediment though. You could perhaps hack it by using the Callbacks plugin and the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
From email:
have a question regarding HTTPX. We use it in some adapter gems to communicate with other systems.
The way our adapter works is that it creates a long lived HTTPX connection (with the Persistent plugin), authenticates itsef with a request (some custom auth protocol), and keeps it around long as the connection works (peer responds to periodic requests) for other requests that the adapter needs to perform. If a request ever fails, the connection object is discarded and a new one is created.
Due to how the Persistent plugin works, this leads to too many open files if the host is not reachable or its name can't be resolved.
I'm not sure what I should do. I can't use HTTPX.wrap due to the async nature of the requests that need to be performed. Is there a way to use the Persistent plugin but still have HTTPX clean up old connections when the corresponding Ruby object goes out of scope?
Right now I don't have access to a test system where the server side for this adapter would be running. So for now I'm just brainstorming.
Should I ...
Let me know what you think. Thanks
Beta Was this translation helpful? Give feedback.
All reactions