开发者

How to tell connection timeout and socket timeout from exception trace stack?

I used apache http client lib in my program. I set both connection timeout and socket timeout for network calls. My understanding is that, if there is connection timeout, the client didn't reach the backend server; if there is socket timeout, the client reached the backend server but the server was not responding or very slow.

I log the following exception trace stack. How can I tell which timeout (connection or socket) caused the exception? Thanks!

java.net.SocketException: The operation timed out
at org.apache.harmony.luni.platform.OSNetworkSystem.connectStreamWithTimeoutSocketImpl(NativeMethod)
at o开发者_运维百科rg.apache.harmony.luni.platform.OSNetworkSystem.connectStreamWithTimeoutSocket(OSNetworkSystem.java:130)
at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:247)
at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:534)
at java.net.Socket.connect(Socket.java:1056)
at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:119)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:143)
at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:348)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)


From the stack trace, you can tell that it timed out while attempting to establish the connection, not while trying to read from the Socket's InputStream.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜