Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7495845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:21:09+00:00 2026-05-29T18:21:09+00:00

This SocketException is thrown in ObjectInputStream.readObject() method, what cause this excetpion? Besides, the values

  • 0

This SocketException is thrown in ObjectInputStream.readObject() method, what cause this excetpion? Besides, the values of soTimeout of client and server socket are both 0, and KeepAlive value is false.

{2012-01-09 17:44:13,908} ERROR java.net.SocketException: Connection timed out
 at java.net.SocketInputStream.socketRead0(Native Method)
 at java.net.SocketInputStream.read(SocketInputStream.java:146)
 at sun.security.ssl.InputRecord.readFully(InputRecord.java:312)
 at sun.security.ssl.InputRecord.read(InputRecord.java:350)
 at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:809)
 at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:766)
 at sun.security.ssl.AppInputStream.read(AppInputStream.java:94)
 at sun.security.ssl.AppInputStream.read(AppInputStream.java:69)
 at java.io.ObjectInputStream$PeekInputStream.peek(ObjectInputStream.java:2265)
 at java.io.ObjectInputStream$BlockDataInputStream.peek(ObjectInputStream.java:2558)
 at    java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2568)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1314)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:368)

From the JAVA API document about the setSoTimeout method, if this method is set a no-zero value, when the times expires, only the SocketTimeoutException was thrown, not the SocketException:Connection timed out, so, this exception should not relate with the setSotimeoutMethod.

public void setSoTimeout(int timeout)  throws SocketException
 Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds. With this 
 option set to a non-zero timeout, a read() call on the InputStream associated with 
 this Socket will block for only this amount of time. If the timeout expires, a 
 java.net.SocketTimeoutException is raised, though the Socket is still valid. The 
option must be enabled prior to entering the blocking operation to have effect. The 
timeout must be > 0. A timeout of zero is interpreted as an infinite timeout.

However, the value returned by PlainSocketImpl(here,is SSLSocketImpl).getTimeout() is transfered by the setSoTimeout() method, then it is still a very strange method.

 SocketInputStream.socketRead0(FileDescriptor fd, byte b[], int off, int len, int timeout)  
  the timeout value is passed in the constructor of  SocketInputStream:SocketInputStream(PlainSocketImpl impl) throws IOException {}
  timeout = impl.getTimeout();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T18:21:15+00:00Added an answer on May 29, 2026 at 6:21 pm

    java.net.SocketException: the Connection timed out exception is not related with setTimeout method, which only is related with the SocketTimedoutException.

    From the messages traces captured by tcpdump, like below:

    NO.            Time       Source Destination Protocol Info
    14845 2012-02-07 22:37:46 10.*   10.*        DNP 3. len=1,from 52156 to 29466,ACK 
    14846 2012-02-07 22:37:46 21.*   10.*        DNP 3. len=1,from 54562 to 50276,ACK
    14848 2012-02-07 22:37:46 32.*   10.*        DNP 3. [TCP Restransmission] len=1,from from 52156 to 29466,ACK 
    ……(7 times retransmission) 
    14849 2012-02-07 22:37:47 10.*   10.*        DNP 3. [TCP Restransmission] len=1,from from 52156 to 29466,ACK
    

    while this logs throw the java.net.SocketException: Connection timed out at 22:54, about 15minutes later from the writeObject invoked.

    So we can conclude that this Exception is caused by that possibly the tcp connection has been not usable because of a long time(about 30minutes) no traffic, meanwhile there is no socket.close() method invoked to close the socket at instance, then this exception was thrown.

    so to avoid this exception, you should keep the connection be alive using the method Socket.setKeepAlive() method although possibly you have not used the method setTimeout(), meaning asking the socket to unlimited block to receive;

    Or apply the heart-beat mechanism in your applications.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found a client/server code and I am getting this error: java.net.SocketException: Software caused
Given this stack trace snippet Caused by: java.net.SocketException: Software caused connection abort: socket write
When the server socket is closed the client doesn't receive any exception even after
This past summer I was developing a basic ASP.NET/SQL Server CRUD app, and unit
if i run Server App. Exception occurs: on Dinle.Start() System.Net.SocketException - Only one usage
ClientAbortException: java.net.SocketException: Broken pipe If I am wright, this happens when user aborts current
This is about when a .NET remoting exception is thrown. If you take a
I have a simple server running on my pc and a simple client on
I have implemented my Server application regarding this post here: http://www.codeguru.com/csharp/csharp/cs_network/sockets/article.php/c8781#Client1 Sum up: I
I've been working on a socket client program in C# and am wondering how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.