embedded
network_error
ai_generated
partial
lwIP:TCP 连接在 SYN-SENT 状态下被对端重置,远程端口 8080
lwIP: TCP connection reset by peer during SYN-SENT state, remote port 8080
ID: embedded/lwip-tcp-connection-reset-during-handshake
75%修复率
82%置信度
1证据数
2024-08-22首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| lwIP 2.1.3 | active | — | — | — |
| FreeRTOS+TCP 2.0.0 | active | — | — | — |
| ESP-IDF 5.1.2 | active | — | — | — |
根因分析
远程主机在 TCP 握手期间发送 RST 包,原因包括防火墙规则、端口关闭或 TCP 窗口缩放选项不匹配。
English
Remote host sends RST packet during TCP handshake due to firewall rules, port closed, or mismatched TCP window scale options.
官方文档
https://www.nongnu.org/lwip/2_1_x/tcp.html解决方案
-
Verify remote port is open using a separate tool (e.g., telnet or nmap from host PC). If port is closed, reconfigure server or firewall rules. For embedded device, add retry logic with exponential backoff in application code.
-
Enable lwIP debug output for TCP events: set LWIP_DBG_ON in lwipopts.h and call tcp_debug_print(TCP_EVENT_CONNECT) to capture RST packet details, then adjust TCP_MSS or TCP_SND_BUF to match server expectations.
无效尝试
常见但无效的做法:
-
Increase TCP SYN timeout in lwIPopts.h (e.g., TCP_SYNMAXRTX = 12)
90% 失败
Timeout increase does not prevent RST; RST is sent by remote host immediately, not a local timeout issue.
-
Disable TCP window scaling by setting TCP_WND to small value
75% 失败
Window scaling mismatch is rarely the cause; disabling it may degrade performance without fixing the RST.