Caused by: java.net.SocketException: Connection reset by peer: socket write error

今天在用WebSocket做客户端连接服务端的时候出现如下异常:

java.io.IOException: java.util.concurrent.ExecutionException: java.net.SocketException: Connection reset by peer: socket write error

异常的详细信息:

Caused by: java.net.SocketException: Connection reset by peer: socket write error_第1张图片

初步分析,是客户端没有正确关闭连接就断开连接造成服务端报以上异常,只要正确关闭客户端的连接就可以了。

正常关闭客户端就不报异常了

Caused by: java.net.SocketException: Connection reset by peer: socket write error_第2张图片

正常关闭客户端连接的核心代码:

Caused by: java.net.SocketException: Connection reset by peer: socket write error_第3张图片

希望能给大家一些参考,谢谢!!!

你可能感兴趣的:(Java,Exception)