udp通信开发工具能收到数据,真机不能?
发布于 5 年前 作者 caiming 6066 次浏览 来自 问答

服务挂个脚本端监听,收到小程序端通过udp发送的数据后又回馈数据到小程序,在开发工具上能正常收发数据,真机上收不到message段数据。

var that = this
    const udp = wx.createUDPSocket(8000)
    udp.bind()
    udp.send({
      address: 'x.x.x.x',
      port: 8000,
      message: ''
    }),
      udp.onMessage(function (res){
      let unit8Arr = new Uint8Array(res.message.data);
      let encodedString = String.fromCharCode.apply(null, unit8Arr);
      let message2 = decodeURIComponent(escape((encodedString)));
        that.setData({
          res_test2:res,
        })
      console.log(that.data.res_test2)
      })

模拟器上能正常收到数据(message段)

真机上收不到(message段)数据,remoteInfo段正常

1 回复

你好,麻烦具体描述问题流程,提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

回到顶部