收藏
回答

connectSocket建立链接成功后立即就被关闭的问题?

that.localSocket = wx.connectSocket({
	url: "wss://test.xxxxxx.com/web/xxxxx/",
	success: data => {
		onsole.log('socket 连接成功', data);
		//this.initSocketListener();
	},
	fail: data => {
		console.error('socket 连接失败', data);
	},
	})
				that.localSocket.onOpen(function (res) {
					console.log('WebSocket连接已打开!readyState=' + that.localSocket.readyState);
					console.log(res, '打开的res数据');
				})
				that.localSocket.onMessage(function(res) {
					console.log('接收socket消息')
					console.log(res)
				})
				that.localSocket.onError(function(res) {
					console.log('socket报错信息', res)
					console.log('readyState=' + that.localSocket.readyState)
				})
				that.localSocket.onClose(function (res) {
					console.log('WebSocket连接已关闭!readyState=' + that.localSocket.readyState)
					console.log(res, '关闭的res数据')
				})


链接被打开后就自己立即再关闭了,请问下这是什么问题?

回答关注问题邀请回答
收藏

1 个回答

  • dust
    dust
    2023-01-12

    同问

    2023-01-12
    有用
    回复 1
    • Ding~
      Ding~
      2023-12-20
      请问解决了吗,还是有这个问题
      2023-12-20
      回复
登录 后发表内容