Worklight 6.2:无法使用 WL.Client.Connect 连接到 Worklight App Server

Worklight 6.2: Unable to connect to Worklight App Server using WL.Client.Connect

我已经面临这个问题 3 天了。需要帮助。

我正在使用 Worklight V6.2 为 Android 和 iOS 创建具有推送通知功能的混合应用程序。在这 2 个环境中发现了不同的问题。

以下是创建应用程序并将其部署到远程服务器的步骤。

  1. 创建混合应用程序
  2. 在 /common/js/main.js 中包含 WL.Client.Connect。还包括 onSuccess 和 onFailure 函数。
  3. 已创建新环境 - 勾选方框 Android、iPhone、iPad
  4. 运行 As -> 搭建所有环境(成功)
  5. 更改构建设置和部署目标。勾选 Build the application to work with a different worklight server。输入 IP (https://:) 和 contextroot(/MyPushProject)。
  6. 运行 作为 -> 运行 在 Worklight 开发服务器上。
  7. 打开远程服务器 Worklight 控制台
  8. 部署 XXXXX-all.wlapp 文件(成功)
  9. 将 android 应用程序导出到 apk 文件。安装在 android 个应用中。
  10. 运行 作为 Xcode 项目 -> 运行 授权 ipad 和 iphone。

以下是两个平台的输出。由于我笔记本电脑的速度和性能,我没有使用 Android 模拟器对其进行测试。

Android: 成功构建并部署到远程服务器。使用网络浏览器查看。

使用 android 预览。 WL.Client.Connect 收到此错误 - https://XX.XX.XXX.XXX:XXXX/MyPushProject/apps/services/api/MyPushApps/android/init。加载资源失败:服务器响应状态为 401(未授权)

iOS(iPad & iPhone): 成功构建并部署到远程服务器。使用网络浏览器查看。

使用 iphone 和 ipad 进行预览。 WL.Client.Connect 成功连接到 Worklight Server。使用 Xcode 7.1 运行 构建应用程序到 iPad 和 iPhone (iOS 9.0) 并收到错误 "Failed to connect to Worklight Server".

来自 xcode 日志:

[错误] [NONE] [https://xxxx.xxxxxxxxx.xxx.xx:444/MyPushProject/apps/services/api/MyPushApps/iphone/init] 主机没有响应。

有人可以告诉我如何解决这个问题吗?非常感谢。

您提供的错误信息有误。对于 Android,您需要查看 LogCat 并从那里提供日志。对于 iOS,您需要查看 Xcode 控制台并从那里提供日志...您还需要提及您使用的 Worklight 6.2 的确切 内部版本号正在使用。

对于iOS,您需要确保在生成时禁用了Apple的应用程序传输安全(ATS),否则您将无法连接到服务器。您可以在此处查看如何执行此操作:https://developer.ibm.com/mobilefirstplatform/2015/09/09/ats-and-bitcode-in-ios9/

在为 Android 和 iOS 生成的本机项目中,您需要查看 worklight.plist (iOS) 和 wlclient.properties (Android) 文件并确保主机、端口和上下文根属性具有您想要的属性,否则应用程序将尝试连接错误的服务器。