简体   繁体   English

什么会导致套接字写入抛出连接超时异常

[英]what will cause socket write throws connection timeout exception

What will cause a write() method throws Connection timeout exception? 什么会导致write()方法抛出连接超时异常?

java.net.SocketException: Connection timed out

    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109)
    at java.net.SocketOutputStream.write(SocketOutputStream.java:153)
    at org.apache.http.impl.io.SessionOutputBufferImpl.streamWrite(SessionOutputBufferImpl.java:126)
    at org.apache.http.impl.io.SessionOutputBufferImpl.write(SessionOutputBufferImpl.java:162)
    at org.apache.http.impl.io.ContentLengthOutputStream.write(ContentLengthOutputStream.java:115)
    at org.apache.http.entity.ByteArrayEntity.writeTo(ByteArrayEntity.java:116)

Connection died (on the way or opposite side of the channel), because for example no communication did not occur for a long time. 连接死亡(在通道的路上或对面),因为例如长时间没有发生通信。 This can be resolved (if you need to) by applying keepAlives on the socket. 这可以通过在套接字上应用keepAlives来解决(如果需要)。

In huge majority of cases - from what I have seen - this is normal behavior exception, because the network partitions do happen from time (this would be a problem if the communication is only in your data center and the exception is common). 在绝大多数情况下 - 从我所看到的 - 这是正常的行为异常,因为网络分区确实是从时间发生的(如果通信仅在您的数据中心并且异常是常见的话,这将是一个问题)。 But if its related to server-client (browser) communication, there should be nothing to worry about. 但如果它与服务器 - 客户端(浏览器)通信有关,那么应该没有什么可担心的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM