java - Getting operation timed out exception on socket read -
if set msocket.setsotimeout(1000);
java.net.sockettimeoutexception: read timed out
after 1 second of wait on msocket.getinputstream().read()
expected.
but, if msocket.setsotimeout(0);
get
java.net.socketexception: operation timed out
after around minute(55 seconds in of runs) of wait puzzling.
i have tried increasing sysctl tcp settings on mac os el capitan no avail. if settings restricted timeout around minute, should have gotten same read timed out exception before. what's operation timed out exception?
edit: worth mentioning deliberately bringing network down using pfctl , since using websockets on tcp expect connection not break given large timeout , flow continue once bring network once again.
the stack trace both exceptions same ie
at java.net.socketinputstream.socketread0(native method) @ java.net.socketinputstream.read(socketinputstream.java:150) @ java.net.socketinputstream.read(socketinputstream.java:121) @ java.net.socketinputstream.read(socketinputstream.java:203) @ org.jwebsocket.kit.websocketprotocolabstraction.protocoltorawpacket(websocketprotocolabstraction.java:220)
when application calls setsotimeout(0)
os may wait data forever. there several kinds of events interrupts read operation regardless so_timeout value.
if os destroys tcp connection behind socket read operation interrupted because tcp connection not exist anymore , there no chance receive data in future. if peer sent data later local tcp stack drop (and perhaps answer tcp-rst).
the os destroyed tcp connection because sent data , did not receive ack. os tried retransmit data , gave after while , destroyed connection.
Comments
Post a Comment