我正在使用NIO线程,其中ServerSocketChannel将被打开,客户端端口将被绑定。但是当我们尝试从Socket chanel读取数据时,下面会提到异常显示。如果有人提供解决方案,那将非常有用。< / p>
Connection reset by peer java.net.SocketException: Transport endpoint is not connected
at sun.nio.ch.SocketChannelImpl.shutdown(Native Method)
at sun.nio.ch.SocketChannelImpl.shutdownOutput(SocketChannelImpl.java:669)
at sun.nio.ch.SocketAdaptor.shutdownOutput(SocketAdaptor.java:386)
at iyp.trncomms.ConnRecordWriter.checkShutDown(ConnRecordWriter.java:131)
at iyp.trncomms.ConnRecordWriter.continueWriting(ConnRecordWriter.java:214)
at iyp.trncomms.ConnRecordWriter.retry(ConnRecordWriter.java:101)
at iyp.trncomms.ConnRecordWriter.shutDown(ConnRecordWriter.java:92)
at iyp.trncomms.ConnRecord$WorkingState.toOnHoldState(ConnRecord.java:1224)
at iyp.trncomms.ConnRecord$WorkingState.onInputError(ConnRecord.java:1152)
at iyp.trncomms.ConnRecord.read(ConnRecord.java:124)
at iyp.trncomms.NIO.run(NIO.java:137)
答案 0 :(得分:0)
Connection reset by peer
非常明确。您打开了连接,但远程端在代码执行之前将其关闭。您需要调查远程系统上的日志,以查看连接过早关闭的原因。
答案 1 :(得分:0)
您似乎在错误情况下调用shutdownOutput()
。这不会起作用:你已经出错了,这将导致另一个错误。关闭频道。