Java socket timeout read timeout exeption

I don’t understand please explain.

When i got
socket.Timeoit Exception read timeout How is it work in default setting in JAVA? Where is manage it? I got timeout after 60 sec.
The some information tell this is manage by
socket.setSoTimeout();
Another resources, this parameter manage on OS level.
First question. What value is default of read timeout and where can i set.
Second
has OS (Linux) level setting of tcp/ip relation to this exeption? Which parameters response for that.
https://www.baeldung.com/linux/tcp-timeout

https://www.ibm.com/docs/en/bcfsoz?topic=tcpip-timeout-behavior-linux-application-server

  • The default read timeout is infinity. You can change it with Socket.setSoTimeout(). You cannot change the default in the operating system as far as I am aware: it is always infinity. Your links are about the connect, ACK, and keepalive timeouts. Neither is relevant to read timeouts.

    – 

I also don’t have actual idea on whats the default socket timeout but according to JBoss docs its 30 minutes i.e. 1800000 milliseconds. This means that any socket operation that does not complete within 30 minutes will throw a SocketTimeoutException.

Yes, as you mentioned you can ovverride the socket timeout as per your requirements by calling setSoTimeout() method on socket object.

Eg:

Socket socket = new Socket(host, port);
socket.setSoTimeout(10000);

And another thing the system/OS has its own settings that affect how it handles network connections, and these settings are separate from the timeout we set in Java.

Leave a Comment