我看到了类似的问题,但我没有找到答案。我正在使用 ksoap2 库与网络服务器连接,有时我得到那个异常 java.net.SocketTimeoutException: read timed out。
这是我的代码:
SoapObject request = new SoapObject(NAMESPACE, method);
if (properties != null) {
for (PropertyInfo property : properties) {
request.addProperty(property);
}
}
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);;
HttpsTransportSE transport = new HttpsTransportSE(HOST, PORT, FILE, TIMEOUT);
transport.debug = true;
transport.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
try {
transport.call(NAMESPACE + "#" + soapAction, envelope);
Object res = (Object)envelope.getResponse();
return res;
} catch (Exception e) {
Log.e("WebService", e.toString());
return null;
}
我可以在某处更改套接字的超时时间还是我能做什么?