egg-socket.io
怎么用啊
试了几次 都失败
我是新手
那个测试的 我也连接失败
你是写单元测试的时候连不上还是写的网页连不上?
[Sun May 07 2017 02:02:29 GMT+0800 (中国标准时间)] [cfork:master:67660] master u
ncaughtException: TypeError: Cannot read property 'send' of undefined
at Server.require.createServer.connection (F:\新建文件夹\example\node_module
s\egg-cluster\lib\master.js:102:7)
at emitOne (events.js:96:13)
at Server.emit (events.js:188:7)
at TCP.onconnection (net.js:1465:8)
TypeError: Cannot read property 'send' of undefined
at Server.require.createServer.connection (F:\新建文件夹\example\node_module
s\egg-cluster\lib\master.js:102:7)
at emitOne (events.js:96:13)
at Server.emit (events.js:188:7)
at TCP.onconnection (net.js:1465:8)
(total 0 disconnect, 0 unexpected exit)
这是提示
我用的是微信小程序的
web() {
wx.connectSocket({
url: 'ws://localhost:7001',
data: {},
header: {
'content-type': 'application/json'
},
method: "GET",
success() {
console.log("成功")
},
fail() {
console.log('失败')
}
})
wx.onSocketOpen(function (res) {
console.log('WebSocket连接已打开!')
})
}
url: 'ws://localhost:7001/socket.io',
改成这样试试看
好像不行额 成功的回调 和失败的回调都没有执行
你config.default.js 里面的配置是什么样子的? config.io 里面的
这是我的QQ 2595488832 我是直接在example 使用 npm run start
请提供最小可复现代码
wx.connectSocket({
url: 'ws://localhost:7001/socket.io/?EIO=3&transport=websocket',
data: {},
header: {
'content-type': 'application/json'
},
method: 'GET',
success() {
console.log('成功')
},
fail() {
console.log('失败')
}
})
wx.onSocketOpen(function (res) {
console.log('WebSocket连接已打开!')
})
这样应该可以了.有几个参数必须要填
socket.io 不是纯粹的 websocket,最好使用 socket.io 的client,其他的就兼容性不保证
不行 还是失败
嗯.感觉跟egg-socket.io 关系不大.
用socket.io的client会自动跟你加上,直接连要自己加.
微信小程序有个库,模拟了socket.io的client 叫wxapp-socket-io
建议去研究下 socket.io和websocket的区别
不行 还是失败
不可能吧... 我刚刚在微信小程序里面用那段代码试的...
你成功是什么样子的 我这边小程序控制机台 只打印了 成功
{errMsg: "connectSocket:ok", statusCode: NaN}
但是 我服务端的控制台却打印出
[Sun May 07 2017 15:11:47 GMT+0800 (中国标准时间)] [cfork:master:110804] master
uncaughtException: TypeError: Cannot read property 'send' of undefined
at Server.require.createServer.connection (F:\新建文件夹\example\node_module
s\egg-cluster\lib\master.js:102:7)
at emitOne (events.js:96:13)
at Server.emit (events.js:188:7)
at TCP.onconnection (net.js:1465:8)
TypeError: Cannot read property 'send' of undefined
at Server.require.createServer.connection (F:\新建文件夹\example\node_module
s\egg-cluster\lib\master.js:102:7)
at emitOne (events.js:96:13)
at Server.emit (events.js:188:7)
at TCP.onconnection (net.js:1465:8)
(total 0 disconnect, 0 unexpected exit)
感谢各位的帮助 我已经成功了 哈哈哈
同学们,是不是可以写篇 egg + 微信小程序聊天的博客啊
发自我的 iPhone
在 2017年5月7日,15:44,z253573760 notifications@github.com 写道:
感谢各位的帮助 我已经成功了 哈哈哈
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
对啊 求大神分享
你们不是搞定了么,写一篇经验总结啊
发自我的 iPhone
在 2017年5月7日,16:58,z253573760 notifications@github.com 写道:
对啊 求大神分享
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
搞定了一点点 而已
微信小程序支持 socket.io 方案:https://github.com/mdluo/socket.io-client-mp