2***@qq.com
2***@qq.com
  • 发布:2019-08-16 20:12
  • 更新:2019-10-15 14:59
  • 阅读:2699

websocket在h5上正常,编译到手机上就连不上

分类:uni-app

对接的网易云信微信IM SDK,在h5上能建立起连接,在手机端不行,截图是h5的链接,下面是app的日志:

20:10:34.247 连接websocket参数"wss://wlnimsc0.netease.im/socket.io/1/websocket/378166b5-af18-4372-a0a5-05aee5a1d882" at uni-app:///sdk/yunxin-wx/vendors/NIM_Web_NIM_weixin_v6.8.0.js:5334  
20:10:34.270 wx::ws: sockets build succeed ... at uni-app:///sdk/yunxin-wx/vendors/NIM_Web_NIM_weixin_v6.8.0.js:5343  
20:10:34.289 连接websocket结果socketTask{"CONNECTING":0,"OPEN":1,"CLOSING":2,"CLOSED":3,"readyState":0} at uni-app:///sdk/yunxin-wx/vendors/NIM_Web_NIM_weixin_v6.8.0.js:5346  
20:10:42.255 "[NIM LOG 08-16 20:10:49:080 IM]  link::reconnect: on socket closed" at uni-app:///sdk/yunxin-wx/vendors/NIM_Web_NIM_weixin_v6.8.0.js:13763  
20:10:42.276 wx::ws:close WebSocket force close: readystate 0 at uni-app:///sdk/yunxin-wx/vendors/NIM_Web_NIM_weixin_v6.8.0.js:5397  
20:10:42.295 WebSocket connection to 'wss://wlnimsc0.netease.im/socket.io/1/websocket/378166b5-af18-4372-a0a5-05aee5a1d882' failed: WebSocket is closed before the connection is established. at __uniappservice.html:0  
20:10:42.315 wx::ws: onerror undefined at uni-app:///sdk/yunxin-wx/vendors/NIM_Web_NIM_weixin_v6.8.0.js:5421  
20:10:42.335 wx::ws: onclose {} at uni-app:///sdk/yunxin-wx/vendors/NIM_Web_NIM_weixin_v6.8.0.js:5359  
20:10:42.355 "[NIM LOG 08-16 20:10:49:120 IM]  link::reconnect: on connectionOver" at uni-app:///sdk/yunxin-wx/vendors/NIM_Web_NIM_weixin_v6.8.0.js:13763  
20:10:42.375 "[NIM LOG 08-16 20:10:49:124 IM]  link::reconnect: will retry after 1605ms, retryCount 1" at uni-app:///sdk/yunxin-wx/vendors/NIM_Web_NIM_weixin_v6.8.0.js:13763  
20:10:42.395 [object CloseEvent] at uni-app:///sdk/yunxin-wx/store/actions/initNimSDK.js:142  
20:10:43.915 "[NIM LOG 08-16 20:10:50:736 IM]  link::connectToUrl: https://wlnimsc0.netease.im:443" at uni-app:///sdk/yunxin-wx/vendors/NIM_Web_NIM_weixin_v6.8.0.js:13763  
20:10:43.955 "[NIM LOG 08-16 20:10:50:772 IM]  link::connectToUrl: socket url: https://wlnimsc0.netease.im:443, transports: [\"websocket\"]" at uni-app:///sdk/yunxin-wx/vendors/NIM_Web_NIM_weixin_v6.8.0.js:13763

我换了3台手机都不行,使用的hbuilderX版本是最新的2.2.1.20190813,他的onerror也不报具体错误,就是连不上

2019-08-16 20:12 负责人:无 分享
已邀请:
DCloud_Android_ST

DCloud_Android_ST

有证书校验吧

  • 2***@qq.com (作者)

    他们的技术说了他们没有问题,让我找找我的原因,但这个东西搞得我也一头雾水,没有具体的错误,在h5一切正常,到了真机就直接进了onerror回调,网上搜索到的是webview不支持websocket,但uniapp使用的是v8吧,跟那个没啥关系

    2019-08-16 21:02

1***@qq.com

1***@qq.com - fighting

编译到手机上就直接进了onerror回调,请问解决了没有。?

5***@qq.com

5***@qq.com

我之前也遇到这种问题
是php那边要求请求头加origin
但是H5默认是有的 App则没有 也不能设置
php直接报错 让后端改吧

该问题目前已经被锁定, 无法添加新回复