IBM Worklight 6.1 - 如何在较慢的网络中处理超时?

时间:2014-01-17 11:46:50

标签: ibm-mobilefirst

我们使用Worklight 6.1iOS5iOS6& IOS7,它的工作非常好。

但是,当我们尝试在 2G网络中使用应用并尝试调用适配器过程时,它甚至连接到服务器。每次我们抽出时间并尝试10-15次后,它将连接到服务器并回复。

当我们在其他优质网络或3G 上使用相同的应用时,它完全没问题。

这是我们在使用2G网络时在Xcode Organizer控制台中的日志:

Jan 17 16:50:53 My-iPad Sec Sec[292] <Warning>: WLRequestBuilder.initWithRootUrl else_url: https://domain.com:443/MyApp/apps/services/api/MyApp/ipad/0/query
Jan 17 16:50:55 My-iPad Sec Sec[292] <Warning>: LSHelperClient: Session started with polling: NO
Jan 17 16:50:59 My-iPad Sec Sec[292] <Warning>: Incorrect NSStringEncoding value 0x0000 detected. Assuming NSASCIIStringEncoding. Will stop this compatiblity mapping behavior in the near future.
Jan 17 16:50:59 My-iPad Sec Sec[292] <Warning>: [ERROR] Worklight: -[WLRequest requestFailed:]:338::Status code='0' error='The request timed out'
Jan 17 16:50:59 My-iPad Sec Sec[292] <Warning>: Incorrect NSStringEncoding value 0x0000 detected. Assuming NSASCIIStringEncoding. Will stop this compatiblity mapping behavior in the near future.
Jan 17 16:50:59 My-iPad Sec Sec[292] <Warning>: Incorrect NSStringEncoding value 0x0000 detected. Assuming NSASCIIStringEncoding. Will stop this compatiblity mapping behavior in the near future.
Jan 17 16:50:59 My-iPad Sec Sec[292] <Warning>: [ERROR] Worklight: -[WLClient onInvokeProcedureFailure:userInfo:]:696::response string=''
Jan 17 16:50:59 My-iPad kernel[0] <Debug>: AppleAP3GDL::handleInterrupt2 FIFO is Empty
Jan 17 16:51:08 My-iPad Sec Sec[292] <Warning>: WLRequestBuilder.initWithRootUrl else_url: https://domain.com:443/MyApp/apps/services/api/MyApp/ipad/0/query
Jan 17 16:51:14 My-iPad Sec Sec[292] <Warning>: Incorrect NSStringEncoding value 0x0000 detected. Assuming NSASCIIStringEncoding. Will stop this compatiblity mapping behavior in the near future.
Jan 17 16:51:14 My-iPad Sec Sec[292] <Warning>: [ERROR] Worklight: -[WLRequest requestFailed:]:338::Status code='0' error='The request timed out'
Jan 17 16:51:14 My-iPad Sec Sec[292] <Warning>: Incorrect NSStringEncoding value 0x0000 detected. Assuming NSASCIIStringEncoding. Will stop this compatiblity mapping behavior in the near future.
Jan 17 16:51:14 My-iPad Sec Sec[292] <Warning>: Incorrect NSStringEncoding value 0x0000 detected. Assuming NSASCIIStringEncoding. Will stop this compatiblity mapping behavior in the near future.
Jan 17 16:51:14 My-iPad Sec Sec[292] <Warning>: [ERROR] Worklight: -[WLClient onInvokeProcedureFailure:userInfo:]:696::response string=''
Jan 17 16:51:17 My-iPad Sec Sec[292] <Warning>: WLRequestBuilder.initWithRootUrl else_url: https://domain.com:443/MyApp/apps/services/api/MyApp/ipad/0/query
Jan 17 16:51:23 My-iPad Sec Sec[292] <Warning>: Incorrect NSStringEncoding value 0x0000 detected. Assuming NSASCIIStringEncoding. Will stop this compatiblity mapping behavior in the near future.
Jan 17 16:51:23 My-iPad Sec Sec[292] <Warning>: [ERROR] Worklight: -[WLRequest requestFailed:]:338::Status code='0' error='The request timed out'
Jan 17 16:51:23 My-iPad Sec Sec[292] <Warning>: Incorrect NSStringEncoding value 0x0000 detected. Assuming NSASCIIStringEncoding. Will stop this compatiblity mapping behavior in the near future.
Jan 17 16:51:23 My-iPad Sec Sec[292] <Warning>: Incorrect NSStringEncoding value 0x0000 detected. Assuming NSASCIIStringEncoding. Will stop this compatiblity mapping behavior in the near future.
Jan 17 16:51:23 My-iPad Sec Sec[292] <Warning>: [ERROR] Worklight: -[WLClient onInvokeProcedureFailure:userInfo:]:696::response string=''
Jan 17 16:51:33 My-iPad Sec Sec[292] <Warning>: WLRequestBuilder.initWithRootUrl else_url: https://domain.com:443/MyApp/apps/services/api/MyApp/ipad/0/query
Jan 17 16:51:40 My-iPad Sec Sec[292] <Warning>: DeviceAuthManager:getWorklightUniqueDeviceId --> returning UUID from the keychain
Jan 17 16:51:40 My-iPad Sec Sec[292] <Warning>: WLRequestBuilder.initWithRootUrl else_url: https://domain.com:443/MyApp/apps/services/api/MyApp/ipad/0/query

让我知道问题是什么以及我们还能为此做些什么。我们的后端API非常快,在毫秒之内我们得到了响应。

我们在程序方面做了什么:

var timeout = 600000;
var invocationOptions = {
  onSuccess: LoginSuccess,
  onFailure: LoginFail,
  timeout: timeout
};

在Adapter XML文件中:

<procedure name="Authentication" requestTimeoutInSeconds="600000"/>  

我们已尝试使用HTTP和HTTPS进行此实验并遇到同样的问题(获取时间)。

当我们启动应用时,我们会收到wlclient init success

2 个答案:

答案 0 :(得分:1)

不要在适配器XML文件中设置高超时。 600.000秒超时意味着用于连接到后端的线程将在超时前等待166.6小时,这很容易导致服务器功能丧失:)

通常,您希望适配器&lt; - &gt;后端超时为应用&lt; - &gt;适配器连接中允许的最高值。例如。如果您在应用中使用的最大超时为60秒 - 这也是适配器&lt; - &gt;后端段中使用的值。

现在,关于app&lt; - &gt;适配器细分。 AFAIR默认超时为30秒。这对于2G网络来说通常也足够了。但是在某些情况下,这可能有点低。您可以使用getNetworkInfo()API(http://pic.dhe.ibm.com/infocenter/wrklight/v6r1m0/index.jsp?topic=%2Fcom.ibm.worklight.apiref.doc%2Fhtml%2Frefjavascript-client%2Fhtml%2FWL.Device.html)来检测您是否使用WIFI / Mobile和3g / 2g等。一旦您在慢速网络上 - 增加您的超时时间。如果你在一个快速的网络上 - 没有理由让用户等待太久,减少你的超时。

答案 1 :(得分:0)

你的后端非常快,但这是一个内部系统。

使用3G或WiFi时,速度通常很快 使用2G或更低时,速度通常要慢得多。

您是否尝试过增加WL.Client.invokeProcedure以及适配器程序中的超时值?

这些将允许客户端和/或服务器等待更长时间来响应。这应该有助于网络速度非常慢的情况。

请参阅以下问题: