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

Adding timeout support to Proxy connection #83

Open
mooyoul opened this issue Nov 19, 2021 · 3 comments
Open

Adding timeout support to Proxy connection #83

mooyoul opened this issue Nov 19, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@mooyoul
Copy link

mooyoul commented Nov 19, 2021

Hello @szmarczak, First of all. I want to say "THANK YOU" - got helped me A LOT and it is fantastic. I really love it. got has a way better timeouts than axios (their timeout handling is broken - PR / Issue), and it has built-in retry support.

Anyway, I've configured H2 over HTTP proxy and just noticed some requests took super long time to fail, or stuck forever.

After some investigation, I noticed that proxy connection can be stuck (or stuck forever) in following cases:

  • ClientRequest of CONNECT method never emit connect event
  • ClientRequest of CONNECT method emitted connect event, but session never created or took long time (~20sec)

this might be edge case because:

  • Long RTT: Origin server is located in Seoul, South Korea and Proxy Peer is located in US
  • Residential Proxy: It is a residential proxy, not a Datacenter Proxy. Some proxy peers has poor network quality.
  • Time-limited, stateless environment: Application is running in AWS Lambda

So, It would be nice if we can handle these situations by supporting timeout to proxy connection.
There might be another way to setting timeouts (or accessing to connection), If so, please let me know!

@szmarczak szmarczak added the enhancement New feature or request label Nov 20, 2021
@mooyoul
Copy link
Author

mooyoul commented Nov 29, 2021

Hey @szmarczak, I've successfully implemented two timeouts - timeout for "CONNECT" method and timeout for complete "secureConnect" event of TLS Socket. I'd like to open PR, but just wondering is there any way to implement H2 session acquire timeout? I've been seeing some poor proxy peers that never created any H2 session after emitting secureConnect event. I want to implement timeout to prevent this, but it seems there's no easy way to implement this. I will be appreciated if you could give some advise!

@szmarczak
Copy link
Owner

@mooyoul
Copy link
Author

mooyoul commented Dec 7, 2021

Ah yes, I missed that H2Session.timeout method exists. Thank you for sharing @szmarczak!

Do you think that session acquire timeout is acceptable? Two timeouts (Connect timeout of CONNECT method and Connect timeout of TLS Socket as I earlier mentioned) can be implemented easily without touching original H2 Agent implementation. Extending Http2OverHttp Proxy Agent can implement these two timeouts, but For "H2 Session Acquire Timeout", There's no easy way to implement without touching original H2 Agent code. So just wondering will you accept this kind of timeout implementation.

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

No branches or pull requests

2 participants