-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Too many open files strikes back #262
Comments
Related to #252 . {
"udp_timeout": 5, // Idling UDP associations will be kept only 5 seconds
"udp_max_associations": 512, // Maximum UDP associations to be kept, unlimited by default
} shadowsocks-libev limits UDP associations to 512 on server, 256 on client. |
Yes. Using max associations sounds like a hack instead of a proper fix though. |
Maybe we can set |
I think there is something else wrong. Do we handle closing udp sockets correctly? (I haven't checked but it might be the case) |
It's a problem. But it should be handled correctly. UDP's sockets are actually stored inside a tokio's task, which will be killed when BTW, #259 is probably not a good idea, which is causing timed out associations couldn't be released in time. |
For reference, you should see
when associations are dropped. |
Connections should be dropped when new connection comes in. I don't think that is an issue. Also it is only a server side change. |
It seems that So it is not possible to set a default proper size limit for udp associations. right? |
Where did you find that Either way, maybe there are
Finally using SOCKS5 UDP ASSOCIATE would help too, but I don't think anyone is connecting to sslocal UDP directly (i.e. without using some tun2socks). |
Drops association when |
Yes but it requires the application to support this On the other hand, maybe if we use |
This is the most prefered solution. |
shadowsocks-rust/src/relay/sys/windows/mod.rs Lines 38 to 48 in 3b47fa6
ICMP port unreachable errors are closed on purpose. On Windows, ICMP port unreachable errors will cause sockets unusable for all subsequence calls |
However, we only use |
It is ok to add a customized function to call |
We need to integrate it with mio too to make it async. |
shadowsocks-rust/src/relay/udprelay/redir/sys/unix/linux.rs Lines 77 to 99 in 3b47fa6
No you don't need mio. |
Tests on macOS: nc -> sslocal -> ssserver -> nc Settings: After the first packet, both
One for communicating with
After 5 seconds, all of these newly created fds are released. So I think there is no fd leaks in UDP association implementation. |
Maybe default timeout of udp associations shouldn't be 5 minutes, which is too long. UDP associations are used mostly for sending one packet. |
UDP sockets can usually send more than one packets... Our implementation of UDP DNS is pretty wasteful. On the other hand, I suspect the issue on those phones are erroneous implementations of UPnP (or something similar) creating a lot of short-lived sessions. |
I have tested with v2ray-plugin's QUIC mode:
And I saw both EDIT: it seems that QUIC won't just keep 1 socket all the time. But the number of sockets are very limited. |
Reverted. |
Similar to #106, I am seeing a lot of errors related to too many open files in shadowsocks-android, more frequently in Xiaomi phones. Probably have to do with UDP association.
The text was updated successfully, but these errors were encountered: