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

Err: Use of closed network connection #60

Open
hussainmohd-a opened this issue Jun 2, 2024 · 1 comment
Open

Err: Use of closed network connection #60

hussainmohd-a opened this issue Jun 2, 2024 · 1 comment
Assignees

Comments

@hussainmohd-a
Copy link

hussainmohd-a commented Jun 2, 2024

2024-06-02 21:23:51.184  8765-17004 GoLog  com.celzero.bravedns  E  multihost.go:142: W multihost: wg5dns no domains or ips
2024-06-02 21:23:51.184  8765-17004 GoLog  com.celzero.bravedns  E  wgconn.go:413: W wg: bind: wg5 recvFrom(invalid AddrPort): 0 / err? read udp4 0.0.0.0:42381: use of closed network connection
2024-06-02 21:23:51.184  8765-17004 GoLog  com.celzero.bravedns  E  wgconn.go:413: W wg: bind: wg5 recvFrom(invalid AddrPort): 0/ err? read udp6 [::]:42381: use of closed network connection
@ignoramous
Copy link
Contributor

I think these are caused by incorrect/stale bound/connected UDP socket.

Currently WireGuard transport creates and connects the underlying UDP socket on start, and uses the same UDP socket for subsequent send/recv. When connected, this UDP socket will bind to a local IP and port.

After network change/recovery, the host's IP address will change, and this UDP socket's local IP address is no long available. The socket API doesn't give any error for UDP on this socket, so it will seem sending successfully (althouth the packet may or may not arrive at the destation) and will receive nothing afterward.

This undetected dead UDP socket also cause problems for IPv6. Some ISP will change your prefix periodically, the host's IPv6 address will change and kill the previously bound UDP socket. And during startup, when the IPv6 address is in tentative state, the connect will succeed but bind to a link local IPv6 address, which also leave a dead socket.

I think the above conditions can be simulated by manually delete/change host's ( bound UDP socket's ) local IP address and tested using docker/netcat.

If we can't easily detect this, maybe we can just recreate/reconnect the UDP socket if haven't received anything for a specific duration.

From: SagerNet/sing-box#1415 (comment)

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