gpt4 book ai didi

android - ksoap2 问题 java.net.ConnectException

转载 作者:行者123 更新时间:2023-11-29 02:03:05 26 4
gpt4 key购买 nike

我正在使用 kSoap2 访问 soap 网络服务。我在执行以下行时收到 java.net.connectException

androidHttpTransport.call(Constants.SOAP_ACTION_GET_METHOD_NAME, envelope)   

这种情况并不总是发生,但有时会发生。这是服务器连接超时的问题吗?如何增加 kSoap 中的连接超时?我用谷歌搜索,但找不到解决方案。谁能建议我解决此错误的解决方案。

Logcat 详细信息如下:

07-17 14:46:24.800: W/System.err(8103): java.net.ConnectException: failed to connect to www.yahoo.com/175.41.138.237 (port 80) after 20000ms: isConnected failed: ENETUNREACH (Network is unreachable)
07-17 14:46:24.800: W/System.err(8103): at libcore.io.IoBridge.isConnected(IoBridge.java:214)
07-17 14:46:24.800: W/System.err(8103): at libcore.io.IoBridge.connectErrno(IoBridge.java:152)
07-17 14:46:24.800: W/System.err(8103): at libcore.io.IoBridge.connect(IoBridge.java:112)
07-17 14:46:24.800: W/System.err(8103): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
07-17 14:46:24.800: W/System.err(8103): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
07-17 14:46:24.800: W/System.err(8103): at java.net.Socket.connect(Socket.java:842)
07-17 14:46:24.800: W/System.err(8103): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:77)
07-17 14:46:24.800: W/System.err(8103): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
07-17 14:46:24.800: W/System.err(8103): at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:351)
07-17 14:46:24.800: W/System.err(8103): at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:86)
07-17 14:46:24.810: W/System.err(8103): at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
07-17 14:46:24.810: W/System.err(8103): at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:308)
07-17 14:46:24.810: W/System.err(8103): at libcore.net.http.HttpEngine.connect(HttpEngine.java:303)
07-17 14:46:24.810: W/System.err(8103): at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:282)
07-17 14:46:24.810: W/System.err(8103): at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:232)
07-17 14:46:24.810: W/System.err(8103): at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:80)
07-17 14:46:24.810: W/System.err(8103): at org.ksoap2.transport.ServiceConnectionSE.connect(ServiceConnectionSE.java:80)

最佳答案

How to increase the connection time out in kSoap ?

HttpTransportSE 在某些情况下忽略超时值似乎仍然存在 Unresolved 问题。看到这个相关link .

但是,对此的解决方案涉及修改现有的 ksoap2 API

感谢 Lightsoftai 的开发人员您现在可以使用以下代码将超时添加到 HttpTransportSE:

注意:您可以为此使用 ksoap2 API 版本 2.5.2 或更高版本

       /**
* Creates instance of HttpTransportSE with set url
*
* @param url
* the destination to POST SOAP data
*/
public HttpTransportSE(String url) {
super(url);
}

/**
* Creates instance of HttpTransportSE with set url
*
* @param url
* the destination to POST SOAP data
* @param timeout
* timeout for connection and Read Timeouts (milliseconds)
*/
public HttpTransportSE(String url, int timeout) {
super(url, timeout);
}

您可以从 here 下载相同的 jar 文件.

另请参阅 ksoap never timeout .

希望对您有所帮助。

关于android - ksoap2 问题 java.net.ConnectException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11541896/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com