AIX:IBM Java:java.net.SocketException:连接超时:可能是由于地址无效

发布于 2024-07-07 03:37:33 字数 2602 浏览 7 评论 0原文

当尝试与我们的服务器建立 SSL 连接时,我们在 IBM AIX 上经常看到以下异常:

java.net.SocketException: Socket closed
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275(Compiled Code))
at com.sun.net.ssl.internal.ssl.AppOutputStream.write(DashoA6275(Compiled Code))
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java(Inlined Compiled Code))
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java(Compiled Code))
at java.io.FilterOutputStream.flush(FilterOutputStream.java(Compiled Code))
at org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java(Compiled Code))
at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java(Compiled Code))
at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java(Compiled Code))
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java(Compiled Code))
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java(Compiled Code))
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java(Compiled Code))
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java(Inlined Compiled Code))
at com.eximtechnologies.httptransport.client.ClientTransport.receiveMessages(ClientTransport.java(Compiled Code))
at com.eximtechnologies.httptransport.client.ClientTransport.receiveMessages(ClientTransport.java(Inlined Compiled Code))
at com.eximtechnologies.ecserver.connection.XMSHTTPConnection.checkForNewMessages(XMSHTTPConnection.java(Compiled Code))
at com.eximtechnologies.ecserver.connection.XMSHTTPConnection.timeoutExpired(XMSHTTPConnection.java(Compiled Code))
at com.eximtechnologies.xmd.timer.TimerEvent$1.run(TimerEvent.java(Compiled Code))

从错误中,您会认为这只是一个网络问题,但客户端在大约 2 个月前从未遇到过该问题, AFAIK,网络布局没有任何变化。

我们也经常收到这样的消息:

java.net.SocketException: Connection timed out:could be due to invalid address
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:336)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:201)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:188)
at java.net.Socket.connect(Socket.java:478)
at java.net.Socket.connect(Socket.java:428)
at java.net.Socket.<init>(Socket.java:335)
at java.net.Socket.<init>(Socket.java:210)
at javax.net.ssl.SSLSocket.<init>(Unknown Source)

我怀疑这是 AIX 问题,但我猜这可能是防火墙问题? 我还在谷歌搜索中看到一些人暗示 commons http 存在问题,但我看不出这有什么关系。

最近其他人在 AIX 上看到过这种情况吗?

We have seen the following exceptions very frequently on IBM AIX when attempting to make an SSL connection to our server:

java.net.SocketException: Socket closed
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275(Compiled Code))
at com.sun.net.ssl.internal.ssl.AppOutputStream.write(DashoA6275(Compiled Code))
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java(Inlined Compiled Code))
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java(Compiled Code))
at java.io.FilterOutputStream.flush(FilterOutputStream.java(Compiled Code))
at org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java(Compiled Code))
at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java(Compiled Code))
at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java(Compiled Code))
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java(Compiled Code))
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java(Compiled Code))
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java(Compiled Code))
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java(Inlined Compiled Code))
at com.eximtechnologies.httptransport.client.ClientTransport.receiveMessages(ClientTransport.java(Compiled Code))
at com.eximtechnologies.httptransport.client.ClientTransport.receiveMessages(ClientTransport.java(Inlined Compiled Code))
at com.eximtechnologies.ecserver.connection.XMSHTTPConnection.checkForNewMessages(XMSHTTPConnection.java(Compiled Code))
at com.eximtechnologies.ecserver.connection.XMSHTTPConnection.timeoutExpired(XMSHTTPConnection.java(Compiled Code))
at com.eximtechnologies.xmd.timer.TimerEvent$1.run(TimerEvent.java(Compiled Code))

From the error, you would think this was just a network problem, but the client had never experienced the problem before about 2 months ago, and AFAIK, there haven't been any changes to the network layout.

We also receive this fairly frequently:

java.net.SocketException: Connection timed out:could be due to invalid address
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:336)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:201)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:188)
at java.net.Socket.connect(Socket.java:478)
at java.net.Socket.connect(Socket.java:428)
at java.net.Socket.<init>(Socket.java:335)
at java.net.Socket.<init>(Socket.java:210)
at javax.net.ssl.SSLSocket.<init>(Unknown Source)

I'm suspecting that this is an AIX problem, but I guess it could be a firewall issue? I also saw some people in google searches hinting at a problem with commons http, but I couldn't see how that would be related.

Is this something that others have seen with AIX recently?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

云胡 2024-07-14 03:37:33

“java.net.SocketException:套接字已关闭”意味着您这边关闭了套接字。 您说当您尝试与服务器建立 SSL 连接时会发生这种情况。 然而,堆栈跟踪表明,当 HTTPClient 尝试通过已建立的连接写入 HTTP 请求时,就会发生这种情况。

例如,如果您以某种方式设法使 HTTPClient 通过先前由 HTTPClient 关闭的连接发送请求,或者更可能是由您这边的其他代码关闭,则可能会发生这种情况。 检查您是否正在某处访问底层套接字。 或者可能是套接字是由 SSL/TLS 协议关闭的(如果我没记错的话,SSL/TLS 有自己的更高级别的协议来关闭底层连接),但 HTTPClient 不知何故设法没有注意到这一点(不要不知道是否可能,但是,比如说,远程端关闭了 SSL 连接,但使用的是 HTTP/1.1 持久连接,并且没有设置 Connection: close 响应)。

您可以通过使用 tcpdump/Wireshark 分析 TCP 流量来解决这些问题。 您还可以在计算机上启动到服务器 HTTPS 端口的隧道,然后使代码通过此隧道通过纯 HTTP 与服务器进行通信。 这将使您能够以明文形式查看 HTTP 流量。

“java.net.SocketException: Connection timed out”表示TCP连接由于超时而无法建立。 可能是数据包被防火墙丢弃。 例如,您可能需要使用 HTTP 代理来发出 HTTPS 请求。 也可能是服务器计算机非常繁忙或网络非常繁忙。 再次,我建议您尝试 tcpdump/Wireshark 来查看 TCP 级别发生了什么。

"java.net.SocketException: Socket closed" means that your side closed the socket. You say that this happens when you attempt to make an SSL connection to your server. However, the stack trace suggests that this happens when HTTPClient attempts to write an HTTP request over an already established connection.

This could happen if, for example, you somehow managed to make HTTPClient send a request via a connection that was previously closed by HTTPClient, or, more likely, by some other code on your side. Check whether you are accessing the underlying socket somewhere. Or it could be that the socket is closed by the SSL/TLS protocol (if I'm not mistaken, SSL/TLS has its own higher-level protocol for closing the underlying connection), but HTTPClient somehow managed to not notice this (don't know whether it's possible, but, say, the remote side closed the SSL connection but was using HTTP/1.1 persistent connections and didn't set a Connection: close response).

You can troubleshoot these issues by analyzing the TCP traffic using tcpdump/Wireshark. You could also start an stunnel on a machine to the server's HTTPS port, then make your code communicate with the server over plain HTTP via this tunnel. This should enable you to see the HTTP traffic in plaintext.

"java.net.SocketException: Connection timed out" means that the TCP connection could not be established due to a timeout. Could be that the packets are dropped by a firewall. For example, it could be that you need to use an HTTP proxy to make HTTPS requests. It could also be that the server machine is really busy or the network is really busy. Again, I suggest you try tcpdump/Wireshark to see what's going on at the TCP level.

就像说晚安 2024-07-14 03:37:33

我遇到了 http 客户端问题,这些问题已通过使用多线程连接得到纠正。 我们通过从下面的第一个配置移动到第二个配置来修复它:

<bean id="httpClient" class="org.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecutor">
    <property name="httpClient">
        <bean class="org.apache.commons.httpclient.HttpClient">
            <property name="connectionTimeout"><value>1000</value></property>
            <property name="timeout"><value>3000</value></property>
        </bean>
    </property>
</bean>

<bean id="httpClient" class="org.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecutor">
    <property name="httpClient">
        <bean class="org.apache.commons.httpclient.HttpClient">
            <property name="connectionTimeout"><value>1000</value></property>
            <property name="timeout"><value>3000</value></property>
            <property name="httpConnectionManager">
              <bean class="org.apache.commons.httpclient.MultiThreadedHttpConnectionManager" destroy-method="shutdown">
                <property name="params">
                  <bean class="org.apache.commons.httpclient.params.HttpConnectionManagerParams">
                    <property name="defaultMaxConnectionsPerHost" value="20" />
                  </bean>
                </property>
              </bean>
            </property>
        </bean>
    </property>
</bean>

I have had issues with http client that were corrected by using a multithreaded connection. We fixed it by moving from the first to the second of the configurations below:

<bean id="httpClient" class="org.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecutor">
    <property name="httpClient">
        <bean class="org.apache.commons.httpclient.HttpClient">
            <property name="connectionTimeout"><value>1000</value></property>
            <property name="timeout"><value>3000</value></property>
        </bean>
    </property>
</bean>

<bean id="httpClient" class="org.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecutor">
    <property name="httpClient">
        <bean class="org.apache.commons.httpclient.HttpClient">
            <property name="connectionTimeout"><value>1000</value></property>
            <property name="timeout"><value>3000</value></property>
            <property name="httpConnectionManager">
              <bean class="org.apache.commons.httpclient.MultiThreadedHttpConnectionManager" destroy-method="shutdown">
                <property name="params">
                  <bean class="org.apache.commons.httpclient.params.HttpConnectionManagerParams">
                    <property name="defaultMaxConnectionsPerHost" value="20" />
                  </bean>
                </property>
              </bean>
            </property>
        </bean>
    </property>
</bean>
神经暖 2024-07-14 03:37:33

如果它不起作用我不会感到惊讶!

指定的超时是从指定的连接管理器获取连接的超时,而不是需要不同设置的实际套接字或服务器超时。

I won't be surprised if it doesn't work!

the specified timeout is the timeout for getting connection from the specified connection manager and not actual socket or server timeout which needs different set of settings.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文