mirror of
https://github.com/mmatczuk/go-http-tunnel.git
synced 2026-05-15 14:16:17 -06:00
[GH-ISSUE #49] Identify dead connections #26
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/go-http-tunnel#26
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @goriccardo on GitHub (Nov 20, 2017).
Original GitHub issue: https://github.com/mmatczuk/go-http-tunnel/issues/49
I'm having issues with long lived connections:
I debugged the issue and found out that once the client is connected to the server this connection is kept open waiting for a user to connect to the server. If the connection dies without notifying the client or server, they would keep listening to dead connections.
If the server believes that a dead connection belonging to an id is open it would reject new (valid) connections from that id.
A client may keep listening to a dead connection forever, effectively preventing the client to retry and open a fresh connection.
My workaround was to turn on TCP keepalive for the client connection, and to let the server ping (http ping) the existing client connection when a connection request with an already connected id is received.
@mmatczuk commented on GitHub (Nov 20, 2017):
For ping I assume you mean https://godoc.org/golang.org/x/net/http2#ClientConn.Ping.
This seems perfectly valid, could you please send a PR.
@goriccardo commented on GitHub (Nov 20, 2017):
Yes that ping :)
I'll prepare a PR tonight, I have to cleanup my workaround a bit.
@mmatczuk commented on GitHub (Nov 20, 2017):
Thanks.
@mmatczuk commented on GitHub (Nov 21, 2017):
Do you have an environment where you could easily reproduce the issue?
@goriccardo commented on GitHub (Nov 21, 2017):
The only way I found to test the issue was using iptables to drop packets to/from the server and kill either the client or the server.
Unfortunately I did not find an easy way to reproduce the bug without using network filtering techniques.
@mmatczuk commented on GitHub (Nov 21, 2017):
Ok that's fine. I have slightly different implementation idea. Will get back to you shortly.
@mmatczuk commented on GitHub (Nov 22, 2017):
@goriccardo could you check if https://github.com/mmatczuk/go-http-tunnel/pull/52 works for you?
@goriccardo commented on GitHub (Nov 22, 2017):
I will test it later today, thanks.
On a side note I was not confident in using the tcpkeepalive package
because apparently there are some known issues reported on its readme. I
did not look at them closely though.
@mmatczuk commented on GitHub (Nov 22, 2017):
The conclusion is to use
SetKeepAlivethat shall be safe see https://github.com/felixge/tcpkeepalive/issues/3.@goriccardo commented on GitHub (Nov 22, 2017):
#52 seems to work fine, thanks.
@mmatczuk commented on GitHub (Nov 22, 2017):
Thanks!
@mmatczuk commented on GitHub (Nov 22, 2017):
Fixed by #52.