1. 程式人生 > >Connection reset by peer原理解析

Connection reset by peer原理解析

“Connection reset by peer”代表什麼?
“Connection reset by peer”表示當前伺服器接受到了通訊對端傳送的TCP RST訊號,即通訊對端已經關閉了連線,通過RST訊號希望接收方關閉連線。

The remote server has sent you a RST packet, which indicates an immediate dropping of the connection, rather than the usual handshake. This bypasses the normal half-closed state transition.

產生RST場景或者導致“Connection reset by peer”場景?

1.當嘗試和未開放的伺服器埠建立tcp連線時,伺服器tcp將會直接向客戶端傳送reset報文;
2.雙方之前已經正常建立了通訊通道,也可能進行過了互動,當某一方在互動的過程中發生了異常,如崩潰等,異常的一方會向對端傳送reset報文,通知對方將連線關閉;
3.當收到TCP報文,但是發現該報文不是已建立的TCP連線列表可處理的,則其直接向對端傳送reset報文;
4.ack報文丟失,並且超出一定的重傳次數或時間後,會主動向對端傳送reset報文釋放該TCP連線;

參考:

https://stackoverflow.com/questions/1434451/what-does-connection-reset-by-peer-mean;
http://lovestblog.cn/blog/2014/05/20/tcp-broken-pipe/;