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

Maintain session-id between requests #25

Open
SavchenkoValeriy opened this issue Mar 19, 2023 · 3 comments
Open

Maintain session-id between requests #25

SavchenkoValeriy opened this issue Mar 19, 2023 · 3 comments
Assignees
Labels
discussion enhancement New feature or request help wanted Extra attention is needed

Comments

@SavchenkoValeriy
Copy link

SSL handshake can take too long if done every time. That can become pretty painful for API users that need multiple serial requests to implement the core functionality. And in general it would make it much faster to call APIs on the same SSL connection.

libcurl can do it, and curl does it by default for multiple requests within one invocation. I don't a way to call curl multiple times and keep connection alive.

@alphapapa
Copy link
Owner

alphapapa commented Mar 19, 2023

Thanks for filing this. Yes, it would be nice to reuse HTTP sessions with curl (e.g. with pipelining), especially to avoid TLS setup.

It may be possible to reuse a curl process to send multiple requests, which would likely solve this. A possible example of how to do so may be seen in Chris Wellons's elfeed-curl library, which inspired plz. See:

https://github.com/skeeto/elfeed/blob/162d7d545ed41c27967d108c04aa31f5a61c8e16/elfeed-curl.el#L221-L256

@alphapapa alphapapa self-assigned this Mar 19, 2023
@alphapapa alphapapa added the enhancement New feature or request label Mar 19, 2023
@alphapapa
Copy link
Owner

However, from a cursory search, it doesn't appear that this is likely to work. See, e.g. https://stackoverflow.com/questions/38857881/curl-command-line-ssl-session-reuse

And it doesn't sound like it's possible to use a single curl process to start making requests while also continuing to listen for instructions to make more requests. What is possible is to instruct a single curl process to make multiple requests, and then have it start making them, reusing connections during the sequence; but it sounds like, when the last request is done, the curl process exits, and the TLS session is discarded.

So a partial solution to this would be to enhance plz's queues to use a single curl process when possible, like elfeed-curl does.

@alphapapa alphapapa added discussion help wanted Extra attention is needed labels Mar 19, 2023
@SavchenkoValeriy
Copy link
Author

Yeah, I also read that thread. As a workaround for fellow wanderers, I can I suggest to use ol' trusty url-retrieve. It keeps connection alive and for my super tiny benchmark of sending many requests to httpbin, it performs ~4 times faster than curl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants