java.net.SocketException: Connection reset

前端 未结 10 1370
慢半拍i
慢半拍i 2020-11-22 03:02

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 th

相关标签:
10条回答
  • 2020-11-22 03:59

    I had the same error. I found the solution for problem now. The problem was client program was finishing before server read the streams.

    0 讨论(0)
  • 2020-11-22 04:00

    Whenever I have had odd issues like this, I usually sit down with a tool like WireShark and look at the raw data being passed back and forth. You might be surprised where things are being disconnected, and you are only being notified when you try and read.

    0 讨论(0)
  • 2020-11-22 04:04

    I also had this problem with a Java program trying to send a command on a server via SSH. The problem was with the machine executing the Java code. It didn't have the permission to connect to the remote server. The write() method was doing alright, but the read() method was throwing a java.net.SocketException: Connection reset. I fixed this problem with adding the client SSH key to the remote server known keys.

    0 讨论(0)
  • 2020-11-22 04:04

    Check your server's Java version. Happened to me because my Weblogic 10.3.6 was on JDK 1.7.0_75 which was on TLSv1. The rest endpoint I was trying to consume was shutting down anything below TLSv1.2.

    By default Weblogic was trying to negotiate the strongest shared protocol. See details here: Issues with setting https.protocols System Property for HTTPS connections.

    I added verbose SSL logging to identify the supported TLS. This indicated TLSv1 was being used for the handshake.
    -Djavax.net.debug=ssl:handshake:verbose:keymanager:trustmanager -Djava.security.debug=access:stack

    I resolved this by pushing the feature out to our JDK8-compatible product, JDK8 defaults to TLSv1.2. For those restricted to JDK7, I also successfully tested a workaround for Java 7 by upgrading to TLSv1.2. I used this answer: How to enable TLS 1.2 in Java 7

    0 讨论(0)
提交回复
热议问题