heiher/natmap

[E] Cannot assign requested address

heiher opened this issue · 0 comments

Log output

[E] ... Cannot assign requested address, Please check is another instance exists or wait a minute.
[E] ... Start TCP keep-alive service failed.

Root cause

In the case where the IP addresses and ports of both the client and server remain unchanged, according to the TCP protocol, after an active connection is closed, it enters the TIME_WAIT state and waits for a short period of time. During this period, if a new connection has the same IP addresses and ports on both ends as the old connection, it will trigger an error indicating that the address is already in use.

在客户端和服务器的IP地址、端口固定不变的情况下,根据TCP协议,一个连接主动关闭后,将转入TIME_WAIT状态并等待一小段时间。在此期间,新的连接如果两端的IP地址和端口与旧的连接相同,则会触发地址不可分配的错误。

Additionally, if there is already an existing natmap instance with the same configuration, such as running in the background, it will also result in the error of address allocation failure.

另外,如果已经存在一个相同配置的natmap实例,比如运行在后台。也会导致地址不可分配的错误。

How to workaround

Firstly, you should check if there is an existing running instance with the same configuration, and if so, you need to stop it before proceeding. As for TIME_WAIT, you don't need to take any action as natmap will automatically retry until it connects to the server. If you cannot tolerate TIME_WAIT, a viable approach is to use dynamic port binding, indicated by -b 0 or -b <port>-<port>. However, this means that the bound port will no longer be fixed.

首先,你应该检查是否存在正在运行的相同配置的实例,如果有需要先停止它。而对于TIME_WAIT,你无需做任何事,natmap会自动重试直到连接上服务器。如果你不能接受发生TIME_WAIT,一个有效的方法是使用动态绑定端口,即 -b 0-b <port>-<port>。但也这意味着绑定端口不再固定。