UDP-dispatcher: fix activity timer cause connection disconnected every minutes#4897
Closed
patterniha wants to merge 1 commit intoXTLS:mainfrom
Closed
UDP-dispatcher: fix activity timer cause connection disconnected every minutes#4897patterniha wants to merge 1 commit intoXTLS:mainfrom
patterniha wants to merge 1 commit intoXTLS:mainfrom
Conversation
885a6c6 to
deb8ca1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
when target-connection is udp, after the first disconnection between xray-client and xray-server, the connection between xray-client and xray-server is disconnected every minute, Let's do the following reproduction-method to understand better:
you need python with
PySockspackage(pip install PySocks)run xray-client and xray-server both on one PC
run echo-server.py with python(
python echo-server.py)this is a simple udp echo server
run echo-socks-client.py with python
this is simple udp echo client that use socks5 protocol to connect
echo-socks-client.py <-> xray-client <-> xray-server <-> echo-server.py
after a few seconds, terminate xray-server and then re-run xray-server (to disconnect connection between client-xray and server-xray, and re-established again)
sniff connection between xray-client and xray-server (loopback-adapter-port-1234)
Then you see that every minute the connection between xray-client and xray-server is disconnected and then re-established.(while the connection is not idle and should not be closed)
///
this is important issue, that causes us to have frequent disconnections between xray-client and xray-server(after first disconnecting with any reason)
Also, because we bind a new port(freedom-udp) in server-side every time, it can cause a lot of problems.
///
Why is this happening?
This is because of this wrong code:
Xray-core/transport/internet/udp/dispatcher.go
Lines 65 to 69 in 1976d02
After previous-connection is closed, it's timer remains active, and after a minute it run
v.RemoveRay()andRemoveRayclosev.conn, but nowv.connis our new connection which is active and should not be closed !!!And this process repeating...
///
other refine:
in
worker.goit is better to cancel ctx after udpConn is closed