JCMais / node-libcurl

libcurl bindings for Node.js
https://npmjs.org/package/node-libcurl
MIT License
660 stars 117 forks source link

How to make multiple curly instances maintain separate connections to same host? #394

Open A-Posthuman opened 11 months ago

A-Posthuman commented 11 months ago

My program makes several curly instances to the same host, but for my use case I prefer that each curly instance maintain a separate SSL HTTP/2 connection, and then "stickily" reuse it. So ideally, there is 1 multiplexed HTTP/2 connection per curly instance, and the same curly instance reuses the same SSL connection - the connections don't get mixed up or used randomly between the curly instances.

Is this possible? When I turn on verbose mode I see messages initially appearing to indicate each new curly instance is making a new connection (I see different "#" connection numbers like 0, 1, and 2 if I make 3 curly instances. But then when I have verbose mode on subsequent requests among the different instances, they all seem to be using connection #0 ?

JCMais commented 10 months ago

sorry for the late reply, you are seeing this behavior because curly is just a wrapper on top of Curl, which is a wrap on top of the more "raw" libcurl APIs: Multi and Easy

The Curl clients (and thus the curly ones) will use a single Multi-instance for all their requests, to achieve what you want to do, you need multiple Multi instances.

Would it be helpful in your case if an option were added that sets the Multi-instance of the Curl/curly calls?

A-Posthuman commented 10 months ago

Yes such an option would definitely be helpful!