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

how to use http_connect with keep-alive #87

Open
stephenkgu opened this issue Feb 14, 2020 · 2 comments
Open

how to use http_connect with keep-alive #87

stephenkgu opened this issue Feb 14, 2020 · 2 comments
Assignees
Labels
API design Discussions about API choices enhancement

Comments

@stephenkgu
Copy link

stephenkgu commented Feb 14, 2020

I sent http request body with the first time on_response, and process the returned second time on_response body.

so, how can I keep a http client connection alive to reuse the http socket connection to some server? Can I do that? @boazsegev

Thanks

@boazsegev
Copy link
Owner

Hi @stephenkgu ,

Thank you for your question and for opening this issue 🙏🏻

Your question is a very good question and it illuminates a design flaw in the current HTTP client.

In theory, you could try to use the http_pause / http_resume features. They were designed for authoring responses, but they could be used for suspending requests... however, this will probably fail if the server disconnects the keep-alive connection before you can use it again.

I believe what you are looking for is a smarter HTTP client feature, allowing you to send requests and receive results without the need to re-establish connections (even if they were lost).

This is a feature that facil.io 0.7.x doesn't have even though it's possible to write one using the existing facil.io API.

I would love to add this to the roadmap, maybe get it working for facil.io 0.9.0 (maybe even added to an 0.8.x releases)... but sadly I don't have time to work on this.

The pieces for a "smart" client are already available. The HTTP/1.1 parser supports both client mode and server mode. You can easily write your own API / extension to make for a nice, persistent, HTTP client.

If you make something nice, I would appreciate a PR. Maybe I can learn from your design and update the simple client to use a better approach.

Thank you for opening this issue!

Kindly,
Bo.

@boazsegev boazsegev self-assigned this Feb 15, 2020
@boazsegev boazsegev added API design Discussions about API choices enhancement labels Feb 15, 2020
@stephenkgu
Copy link
Author

Thanks, I used facil for few months. It's a great work, plenty of useful features.

But, I have few experiences with http client, and know little with facil. I will try to make a connection reuse client before the 0.9.0(or 0.8.x).

Regards,
stephen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API design Discussions about API choices enhancement
Projects
None yet
Development

No branches or pull requests

2 participants