小程序
小游戏
企业微信
微信支付
扫描小程序码分享
小程序服务和websocket使用域名访问,websocket无法连接但code200
appservice?t=1560474138273:1305 WebSocket connection to 'wss://xxx.com/ failed: Error during WebSocket handshake: Unexpected response code: 200
1 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
还在微信开发者工具上测试
服务端
const Koa = require('koa');
var app = new Koa();
const fs = require('fs');
const http = require('http');
const https = require('https');
const server = http.createServer(app.callback());
var WebSocket = require('ws');
var WebSocketServer = WebSocket.Server;
wss = new WebSocketServer({server,verifyClient: ClientVerify});
const httpsOption = {
key: fs.readFileSync("./https/xxx.key"),
cert: fs.readFileSync("./https/xxx.pem")
};
server.listen(80);
https.createServer(httpsOption,app.callback()).listen(443);
客户端
webSocketTask = wx.connectSocket({ url: 'wss://xxx.com/?id=luoc83&key=KiddLo09', header: { 'content-type': 'application/json' }, method: 'POST', success: function (res) { wx.hideLoading(); }, fail: function (err) { wx.hideLoading(); wx.showToast({
代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)这个格式的代码片段
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)
还在微信开发者工具上测试
服务端
const Koa = require('koa');
var app = new Koa();
const fs = require('fs');
const http = require('http');
const https = require('https');
const server = http.createServer(app.callback());
var WebSocket = require('ws');
var WebSocketServer = WebSocket.Server;
wss = new WebSocketServer({server,verifyClient: ClientVerify});
const httpsOption = {
key: fs.readFileSync("./https/xxx.key"),
cert: fs.readFileSync("./https/xxx.pem")
};
server.listen(80);
https.createServer(httpsOption,app.callback()).listen(443);
客户端
webSocketTask = wx.connectSocket({
url: 'wss://xxx.com/?id=luoc83&key=KiddLo09',
header: {
'content-type': 'application/json'
},
method: 'POST',
success: function (res) {
wx.hideLoading();
},
fail: function (err) {
wx.hideLoading();
wx.showToast({
代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)这个格式的代码片段