求助求助!mqtt,websocket问题
发布于 4 年前 作者 xuetao 5650 次浏览 来自 问答
  • 当前 Bug 的表现(可附上截图)

RT,开发者工具可以成功链接 但真机无法链接。

服务器:

    nginx 1.14.2

    nginx配置:

 

server {

        listen       443 ssl;

        server_name  https.dnanren.cn;

ssl on;

ssl_certificate C:/nginx/nginx-1.14.2/conf/ssl/ssl.pem;

        ssl_certificate_key C:/nginx/nginx-1.14.2/conf/ssl/ssl.key;

ssl_session_timeout 5m;

  ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;

  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

  ssl_prefer_server_ciphers on;

root /opt/nginx/wwwroot/laravel/public;

index index.php index.html index.htm;

        location /mqtt{

proxy_pass https://https.dnanren.cn:8084;

proxy_redirect off;

proxy_set_header Host https://https.dnanren.cn:8084;

proxy_set_header Sec-WebSocket-Protocol mqtt;

#more_clear_headers Sec-WebSocket-Protocol;

    proxy_http_version 1.1;

    proxy_set_header Upgrade $http_upgrade;

    proxy_set_header Connection “upgrade”;

        }

location /ws{

proxy_pass http://https.dnanren.cn:8888;

#rewrite /mqtt;

    proxy_http_version 1.1;

    proxy_set_header Upgrade $http_upgrade;

    proxy_set_header Connection “upgrade”;

        }

location / {

            root   html;

            index  index.html index.htm;

        }

    }

    ssl安全证书类型 DV

    MQTT服务器使用emq2.x

    小程序客户端mqtt库使用 paho-mqtt

    域名已备案

    服务器百度云的

    小程序后台服务器域名已配置。

    小程序访问时 使用wss://https.dnanren.cn/mqtt

    出现的问题就是真机无法链接成功。开发者工具中不管开不开启安全域名校验都能链接成功。

    2019年2月2日 21点43分 测试mqtt真机预览 体验版连接成功,相信是微信官方团队修复了这个问题了。我也安心过年了 虽然没有公告发出来。也特别感谢微信团队及时修复问题。祝新年快乐!

  • 预期表现

成功链接

  • 复现路径
  • 提供一个最简复现 Demo
7 回复

实在是解决不了,同问,急的我都过不了年了

是安卓的无法连接还是ios的呢?

上周社区问题反馈以及功能优化更新(01.21-01.25)官

修复日志,说已经修复了:部分 Android7.0 用户 websocket 线上版本无法连接问题

不过还是有人测试发现7.0.3 websocket连不上。

可以尝试下面这个做法看能否解决:

把服务器去掉这个:

proxy_set_header Sec-WebSocket-Protocol mqtt;

然后小程序代码加上黑体部分

var ws = wx.connectSocket({

      url: ‘wss://https.dnanren.cn/mqtt’,

      protocols: [‘mqtt’]

    })

小弟我 已经困扰几天了。实在没招了

怎么样啊?我也遇到这个问题,一起讨论下,据说是证书问题,部分手机不支持

回到顶部