MikeWang000000 / Natter

Expose your TCP/UDP port behind full-cone NAT to the Internet.
GNU General Public License v3.0
1.64k stars 137 forks source link

fwd-socket: cannot forward port: Too many threads #97

Open Winterwxd opened 5 months ago

Winterwxd commented 5 months ago

版本v2,tcp打洞后可以访问,过段时间(几个小时)就报这个错误: 2024-06-11 10:04:38 [I] tcp://192.168.3.7:22240 <--socket--> tcp://192.168.3.7:40993 <--Natter--> tcp://122.97.183.24:3207 2024-06-11 10:04:38 [I] 2024-06-11 10:04:38 [I] LAN > 192.168.3.7:22240 [ OPEN ] 2024-06-11 10:04:38 [I] LAN > 192.168.3.7:40993 [ OPEN ] 2024-06-11 10:04:38 [I] LAN > 122.97.183.24:3207 [ OPEN ] 2024-06-11 10:04:39 [I] WAN > 122.97.183.24:3207 [ OPEN ] 2024-06-11 10:04:39 [I] 2024-06-11 15:44:16 [E] fwd-socket: cannot forward port: Too many threads 2024-06-11 15:44:16 [E] fwd-socket: cannot forward port: Too many threads 2024-06-11 15:44:25 [E] fwd-socket: cannot forward port: Too many threads 2024-06-11 15:49:25 [E] fwd-socket: cannot forward port: Too many threads 2024-06-11 15:54:17 [E] fwd-socket: cannot forward port: Too many threads

MikeWang000000 commented 5 months ago

Natter 的 socket 方法会限制线程数,self.max_threads 定为 128,防止系统资源耗尽。 如果服务需要大量并发连接,推荐改用 iptables 等其他方法。

https://github.com/MikeWang000000/Natter/blob/f8257e8cff8f013202d9af9d0f9af4d986c1c718/natter.py#L881-L889

ApliNi commented 4 months ago

请问一下在 Windows 上有没有可能实现一个高效且能保留源 IP 的转发方法? 我之前有使用过 Lucky 工具通过 UPNP 开放端口发现它可以保留源 IP, 但是 Lucky 有时候不稳定.