weapp-socketio / wxapp-socket-io Goto Github PK
View Code? Open in Web Editor NEW此项目已经迁移至:
Home Page: https://github.com/wxsocketio/weapp.socket.io
此项目已经迁移至:
Home Page: https://github.com/wxsocketio/weapp.socket.io
我是这样写的
const io = require('./ws.js');
const news = io('wss://xxx.com/venice/v1/user/')
控制台报错
WebSocket connection to 'wss://xxx.com/socket.io/?EIO=3&transport=websocket' failed: Error during WebSocket handshake: Unexpected response code: 502
当我后端发送类型为对象的值时,内部的decodePacket
函数中的 data.charAt(0)为报错 , 由于源代码逻辑对我来说比较复杂,希望作者可以修复一下。感谢。
Should be single instance while wxapp only allowed 1 websocket instance
那个ws://chat.socket.io不能用呀,现在小程序不能和后台代码连接上。请问大神能不能配一个服务端的代码呢?不知道服务端的代码要怎么写唉。。。
微信小程序使用中,微信开发者工具上可以连接上无报错,但是在真机测试时,报错 TypeError:JSON.stringify cannot serialize cyclic structures. 如何解决?orz
小程序里面这样写是可以的,
wx.connectSocket({
url: 'wss://xxxx.com/user/??EIO=3&transport=websocket',
})
在socket.io的客户端是这样写的
io.connect('//xxxx.com',{path:'/user'});
在你这里应该咋写,写成?path=user
也不管用啊,貌似加了个默认通道socket.io
,
控制台报错,连接地址为
wss://xxx.com/socket.io/?path=/user/&EIO=3&transport=websocket'
这个了,
import io from 'wxapp-socket-io'
var socket = io('https://xxx.xxx.net/socket/socket.io')
生成出来的地址不对,不写端口好像不行,而且端口后面的路径无法自己控制,怎么写都是生成:https://xxx.xxx.net:xxx/socket.io/?EIO=3&transport=websocket
web连接的demo是可以正常连接的:
var socket = io.connect('https://xxx.xxx.net', {path: "/socket/socket.io"});
求教
用的是demo中wxsocket.io里面的版本
const socket = io('wss://socket.example.com')
wx.onSocketOpen((res) => {
//这样服务端没有收到消息
socket.emit('foo', 'bar')
//这样服务端可以收到消息
wx.sendSocketMessage({
data: [4, 2, JSON.stringify(['foo', 'bar'])].join('')
})
})
this.engine.close is not a function.
将源码的 if (this.engine) this.engine.close()改成if (this.engine) this.engine.destroy()之后可以断开连接。但是再次 socket.connect()之后 掉线频率太快。
像manager.js里面的'component-emitter' | 'component-bind' | 'backo2' | 'indexof' 这些import都是从哪里引用的啊?
Maybe the url should be changed to an invite link?
socket.on('disconnect', function () {
console.log('disconnect')
socket.io.reconnect();
});
只会尝试重连一次,不会循环尝试。
建议Demo
项目里添加使用Socket.IO官方的Chat Demo,因为这种方式下,开发者不需要再去搭建一个本地server,就可以直接测试看到交互效果了。
同时,现在的Demo里,还夹杂了与演示咱们wxapp-socket-io无关的一些代码,建议都去掉,这样会更简洁明了的讲述咱们项目的使用之方便~
微信小程序里不能直接用socket.io client客户端库?还要自己封装写一套?
我找的 server 好像都不好用啊
用的socket.io 0.9.x的 一直报 info - unhandled socket.io url
求大神上传一个 配套的 server
非常急, 我是js新手 ,还请大神有时间了 速度更新
代码如下,当第二次连接指定query时, socket无法更新
socket = io(socket_url + roomid, {
query: "openid=" + openid + "&sessionid=" + sessionid,
upgrade: false,
transports: ['websocket']
});
socket.connect()
WAService.js:1 thirdScriptError
this.engine.close is not a function;at onSocketMessage callback function
TypeError: this.engine.close is not a function
at Manager.close.Manager.disconnect (http://1603736195.appservice.open.weixin.qq.com/vendor/socket.io/index.js:394:38)
at Manager.destroy (http://1603736195.appservice.open.weixin.qq.com/vendor/socket.io/index.js:382:14)
at Socket.destroy (http://1603736195.appservice.open.weixin.qq.com/vendor/socket.io/index.js:1907:17)
at Socket.close.Socket.disconnect (http://1603736195.appservice.open.weixin.qq.com/vendor/socket.io/index.js:1892:14)
at Socket.onpacket (http://1603736195.appservice.open.weixin.qq.com/vendor/socket.io/index.js:1862:18)
at Manager.<anonymous> (http://1603736195.appservice.open.weixin.qq.com/vendor/socket.io/index.js:672:21)
at Manager.Emitter.emit (http://1603736195.appservice.open.weixin.qq.com/vendor/socket.io/index.js:615:26)
at http://1603736195.appservice.open.weixin.qq.com/vendor/socket.io/index.js:272:18
at Manager.decoder (http://1603736195.appservice.open.weixin.qq.com/vendor/socket.io/index.js:1677:9)
at Manager.ondata (http://1603736195.appservice.open.weixin.qq.com/vendor/socket.io/index.js:271:14)
如题,支付宝小程序已经公测阶段了,看了接口和微信非常相似,因此希望能否提供一个支付宝版本的,非常感谢
如题
如果使用 io('https://abc.com'), 微信会报 wss://abc.com: 不在白名单。
转化成wss的时候最后多了一个:
使用 io('wss://abc.com') 则正常
大约每隔1分41秒就会重连。
我的demo每51秒就会重连一次,改了pingInterval 和pingTimeout 之后。只是间隔时间不一样了。但是还是会重连
小程序代码如下
var socket = io('http://192.168.3.88:8005/game',{query:param});
console.log('chat: ', socket)
socket.on('connect',function(data){ console.log('connect',data) }) socket.on('connected',function(data){ console.log('connected',data) })
打印结果:(connected=false, 可是服务器任然是保持连接的)
chat: Socket {io: Manager, nsp: "/game", id: 0, connected: false, disconnected: true…}
如何才能调用连接 并正确监听事件
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.