java.net.SocketException:连接重置 [英] java.net.SocketException: Connection reset

查看:3911
本文介绍了java.net.SocketException:连接重置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到以下错误尝试从套接字读取。我在 InputStream 上做一个 readInt(),我得到这个错误。通过文档,这表明客户端部分的连接关闭了连接。在这种情况下,我是服务器。



我可以访问客户端日志文件,它不关闭连接,实际上其日志文件建议我关闭连接。任何人都有一个想法为什么这种情况发生?还有什么要检查?这是否出现在当地资源可能达到阈值?






我注意到,我有以下行:

  socket.setSoTimeout(10000); ( readInt()之前的



<有一个原因(长的故事),但只是好奇,有什么情况下,这可能会导致指出的错误?我有服务器运行在我的IDE,我碰巧让我的IDE卡在一个断点,然后我注意到完全相同的错误开始出现在我自己的日志在我的IDE。



无论如何,只是提到它,希望不是一个红色的鲱鱼。 : - (

解决方案

有几种可能的原因。


  1. 另一端有意地重置连接,在这里我不会记录这是罕见的,一般不正确的应用软件这样做,但它不是未知的商业软件


  2. 更常见的是,它是由于写入一个连接而造成另一端已经正常关闭,换句话说是应用程序协议错误。



  3. < >

    在Windows中,软件导致连接中止,这与连接重置不一样,是由于您发送网络问题引起的。有关于此的Microsoft知识库文章。

    li>


I am getting the following error trying to read from a socket. I'm doing a readInt() on that InputStream, and I am getting this error. Perusing the documentation this suggests that the client part of the connection closed the connection. In this scenario, I am the server.

I have access to the client log files and it is not closing the connection, and in fact its log files suggest I am closing the connection. So does anybody have an idea why this is happening? What else to check for? Does this arise when there are local resources that are perhaps reaching thresholds?


I do note that I have the following line:

socket.setSoTimeout(10000);

just prior to the readInt(). There is a reason for this (long story), but just curious, are there circumstances under which this might lead to the indicated error? I have the server running in my IDE, and I happened to leave my IDE stuck on a breakpoint, and I then noticed the exact same errors begin appearing in my own logs in my IDE.

Anyway, just mentioning it, hopefully not a red herring. :-(

解决方案

There are several possible causes.

  1. The other end has deliberately reset the connection, in a way which I will not document here. It is rare, and generally incorrect, for application software to do this, but it is not unknown for commercial software.

  2. More commonly, it is caused by writing to a connection that the other end has already closed normally. In other words an application protocol error.

  3. It can also be caused by closing a socket when there is unread data in the socket receive buffer.

  4. In Windows, 'software caused connection abort', which is not the same as 'connection reset', is caused by network problems sending from your end. There's a Microsoft knowledge base article about this.

这篇关于java.net.SocketException:连接重置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆