ssh2 icon indicating copy to clipboard operation
ssh2 copied to clipboard

Question: HTTPSAgent reuse

Open lukasa1993 opened this issue 1 year ago • 3 comments

any way to reuse ssh2 connection for node-fetch agent ?

i am using ssh2.HTTPSAgent agent with node-fetch to pass thru http requests, all works perfectly only thing is it reconnects on each requests and that adds bit of a delay if i can reuse ssh2 connection would'd be way faster

lukasa1993 avatar Jan 22 '24 11:01 lukasa1993

Reusing a connection is not currently supported for HTTP(S) agents. The reason being that's the only sure way to make sure the server will have a channel available to process the request.

Additionally, connection reuse complicates things a little bit since that would require maintaining a pool of SSH connections.

Adding support isn't impossible, but for now it's just not supported.

mscdex avatar Jan 22 '24 12:01 mscdex

can i somehow do dirty solution which just tris if server had connection room and doesn't guarantee it ?

lukasa1993 avatar Jan 22 '24 16:01 lukasa1993

I'm not sure what you're asking exactly, but there is nothing stopping you from copying the existing implementation and tweaking it for your own needs.

mscdex avatar Jan 22 '24 17:01 mscdex