Java Socket Programming Error Connection reset by Peer__java

Source: Internet
Author: User
Tags connection reset

During the socket programming process, the client sends a request to the server and encounters the following error: Java.net.SocketException:recvfrom failed:econnreset (Connection reset by Peer)

01-11 23:07:25.065:w/system.err (11804): Java.net.SocketException:recvfrom failed:econnreset (Connection reset by peer )
01-11 23:07:25.073:w/system.err (11804): at 	Libcore.io.IoBridge.maybeThrowAfterRecvfrom (Iobridge.java : 634)
01-11 23:07:25.073:w/system.err (11804): at 	libcore.io.IoBridge.recvfrom (iobridge.java:596)
01-11 23:07:25.073:w/system.err (11804): at 	java.net.PlainSocketImpl.read (plainsocketimpl.java:492)
01-11 23:07:25.073:w/system.err (11804): at 	java.net.plainsocketimpl.access$000 (plainsocketimpl.java:42)
01-11 23:07:25.073:w/system.err (11804): at 	Java.net.plainsocketimpl$plainsocketinputstream.read ( plainsocketimpl.java:242)
01-11 23:07:25.073:w/system.err (11804): at 	Java.io.BufferedInputStream.read ( bufferedinputstream.java:290)
01-11 23:07:25.073:w/system.err (11804): 	at Com.emp.common.pos.JConnection.read (jconnection.java:185)

Debugging this error, the most annoying is the two sides, find the root cause of the problem, the client said server processing problems, the server said the client code is wrong.


Client clearly access to other channels is no problem, why access to the channel will be an error. Then the server has not received the request. First, analyze the wrong translations:

Connection Reset by Peer: The connection is side equal. So what does peer mean. There is this passage:


The client is the originator of the communication, and the server program passively waits for the client to initiate the communication and respond to it.
Whether a program is a client or a server determines the socket APIs that it uses to establish communications with its peers (peer) (the client's peer is the server and vice versa).


It is clear that the following conclusions have been drawn:

1, the client's peer is the server, the server peer is the client;

2, the client access to other channels before the normal communication, indicating that the client code error probability is not high, the server to deal with the suspected sudden rise;

3, the server reset the connection. At the very least, the server received the request message, because for some reason the processing data failed, forced to reset the connection.


Finally, after the investigation and confirmation, it confirms our conclusion, the server in processing message length error. The two sides coordinate the correction, finally the communication succeeded.








Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.