Home > database >  Why socks5 UDP association terminates when the TCP connection that the UDP ASSOCIATE request arrived
Why socks5 UDP association terminates when the TCP connection that the UDP ASSOCIATE request arrived

Time:12-15

As socks5 rfc says,

A UDP association terminates when the TCP connection that the UDP ASSOCIATE request arrived on terminates.

I wonder, doesn't "the TCP connection that the UDP ASSOCIATE request arrived on" just terminate when it timeouts? As there is no more data need to be sent in that TCP connection.

Should the client send meaningless data in that TCP connection just to keep it alive while it need the UDP association?

CodePudding user response:

I wonder, doesn't "the TCP connection that the UDP ASSOCIATE request arrived on" just terminate when it timeouts?

No. The TCP connection is kept alive as a signal that the proxied UDP socket is still valid. Without it, the client has no way of knowing whether the server is still reachable or whether the UDP socket is still allocated.

Similarly, without the TCP connection the server has no other way of knowing whether the client is still connected.

Should the client send meaningless data in that TCP connection just to keep it alive while it need the UDP association?

There's no need to send meaningless data. Just keep the connection alive. TCP has a built-in keepalive mechanism which can be turned on.

Edit: It's worth pointing out that the default TCP keepalive times on both Linux and Windows is fairly long. See this question on ways of tweaking it for specific sockets.

  • Related