MikeWang000000 / Natter

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

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

Open Winterwxd opened 2 weeks ago

Winterwxd commented 2 weeks 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 2 days ago

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

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