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

it seems that no way to set Http2 connection with timeout #41

Closed
superzmy opened this issue Sep 9, 2023 · 2 comments
Closed

it seems that no way to set Http2 connection with timeout #41

superzmy opened this issue Sep 9, 2023 · 2 comments

Comments

@superzmy
Copy link

superzmy commented Sep 9, 2023

while TcpSocket::Impl::connect has timeout_ms arg,
but TcpConnection didn't pass this arg.

close() outside seems useless when connecting.

    // http is kuma::HttpRequest
    std::function<void()> fReconnect = [&] {
        puts("Reconnect");
        http.close();
        http.sendRequest("GET", "https://xxxxxxxxxxxx/");
        timerReconnect.schedule(1000, Timer::Mode::ONE_SHOT, fReconnect);
    };
    timerReconnect.schedule(1000, Timer::Mode::ONE_SHOT, fReconnect);

I had to insert this code into SocketBase::connect

    if (timeout_ms == 0)
        timeout_ms = 100;

and then it seems better to quick reconnect.

@superzmy
Copy link
Author

superzmy commented Sep 9, 2023

totally I need a way to http2 sendRquest(...) in a not very good network, sometimes it lose packet so connect will wait seconds until timeout, but if recall in another process it can success quickly.
Now the kuma::HttpRequest::close() and sendRequest in timer seems useless.
And even I force SocketBase::connect timeout_ms to 100ms and close&sendRequest after first400ms is no response come, In rare cases I wait many seconds to get first error Callback and after then the close&sendRequest can tack effect.
So is someway to force destroy socket of HTTP2 in any situation and reconnect?

@Jamol
Copy link
Owner

Jamol commented Apr 21, 2024

Now H2Connection::getConnection is ready to get underlying connection for http2 request, and you can close it with returned connection

@Jamol Jamol closed this as completed Apr 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants