Clientabortexception: java.net. socketexception

Source: Internet
Author: User
Tags connection reset

Clientabortexception: java.net. socketexception: Connection reset by peer: Socket write error

I. exception description:

When you use jfreechart to output chart images to a browser, if the refresh is too fast, the following exception occurs:

Clientabortexception: java.net. socketexception: Connection reset by peer: Socket write error

The Code is as follows:

Clientabortexception: java.net. socketexception: Connection reset by peer: Socket write error
At org. Apache. Catalina. connector. outputbuffer. realwritebytes (outputbuffer. Java: 358)
At org. Apache. tomcat. util. Buf. bytechunk. flushbuffer (bytechunk. Java: 434)
At org. Apache. tomcat. util. Buf. bytechunk. append (bytechunk. Java: 349)
At org. Apache. Catalina. connector. outputbuffer. writebytes (outputbuffer. Java: 381)
At org. Apache. Catalina. connector. outputbuffer. Write (outputbuffer. Java: 370)
At org. Apache. Catalina. connector. coyoteoutputstream. Write (coyoteoutputstream. Java: 89)
At javax. ImageIO. Stream. filecacheimageoutputstream. flus+fore (filecacheimageoutputstream. Java: 230)
At javax. ImageIO. Stream. imageinputstreamimpl. Flush (imageinputstreamimpl. Java: 811)
At com.sun.imageio.plugins.jpeg. Adjust imagewriter. Write (using imagewriter. Java: 1027)
At org. jfree. Chart. encoders. sunbench encoderadapter. encode (sunbench encoderadapter. Java: 173)
At org. jfree. Chart. encoders. encoderutil. writebufferedimage (encoderutil. Java: 137)
At org. jfree. Chart. chartutilities. writechartasjpeg (chartutilities. Java: 443)
At org. jfree. Chart. chartutilities. writechartasjpeg (chartutilities. Java: 389)

Caused by: java.net. socketexception: Connection reset by peer: Socket write error
At java.net. socketoutputstream. socketwrite0 (native method)
At java.net. socketoutputstream. socketwrite (socketoutputstream. Java: 92)
At java.net. socketoutputstream. Write (socketoutputstream. Java: 136)
At org. Apache. Coyote. http11.internaloutputbuffer. realwritebytes (internaloutputbuffer. Java: 741)
At org. Apache. tomcat. util. Buf. bytechunk. flushbuffer (bytechunk. Java: 434)
At org. Apache. tomcat. util. Buf. bytechunk. append (bytechunk. Java: 349)
At org. Apache. Coyote. http11.internaloutputbuffer $ outputstreamoutputbuffer. dowrite (internaloutputbuffer. Java: 765)
At org. Apache. Coyote. http11.filters. chunkedoutputfilter. dowrite (chunkedoutputfilter. Java: 126)
At org. Apache. Coyote. http11.internaloutputbuffer. dowrite (internaloutputbuffer. Java: 574)
At org. Apache. Coyote. response. dowrite (response. Java: 560)
At org. Apache. Catalina. connector. outputbuffer. realwritebytes (outputbuffer. Java: 353)
... 47 more
 

Ii. Cause Analysis

I found the following reason in Baidu:
Clientabortexception:Java.net. socketexception: Connection reset by peer: Socket write error is caused by a "clientabortexception ", it is an exception in I/O processing and should be captured by the application server.
Connection reset by peerCause:
Frequent Connection reset by peer: there may be many reasons, but the more common reasons are:
①: When the number of concurrent connections on the server exceeds its capacity, the server will shut down some of the connections;
②: The client closes the browser, and the server is still sending data to the client;
③: The browser presses stop.
Many people say that it is caused by the client and there is no way to control it. This is a depressing problem.
 

However, a buddy said well, ifClientabortexception:Yes. Do not output these exceptions.

Specific methods

Code:
  1. Try {
  2. // Put the processing code in try ...... In the Catch Block, use the judgment function in the catch part to prevent the system from throwing clientabortexception,
  3. Chartutilities. writechartasjpeg (response. getoutputstream (), chart, 600,400 );
  4. } Catch (exception e ){
  5. String simplename = E. getclass (). getsimplename ();
  6. If ("clientabortexception". Equals (simplename )){
  7. System. Out. println ("refreshing the client too fast ");
  8. } Else
  9. E. printstacktrace ();
  10. }
  11. Return Mapping. findforward ("succ ");
  12. }

 

Iii. Conclusion

This is acceptable.

 

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.