java, 网络

Java mqtt client 连接 wss url

By jere on 2019-07-11 0 Comments

Java client: org.eclipse.paho:org.eclipse.paho.client.mqttv3

连接 wss 地址,比如 wss://xxx.com。因为此 client 用的是 v3 版本,所以在 nginx 需要做相应处理。
然后把地址修改成: wss://yourserver/mqtt31

location /mqtt31 {
proxy_set_header Host $http_host;
proxy_pass http://xxxx:port;

proxy_set_header Sec-WebSocket-Protocol mqttv3.1;
proxy_http_version 1.1;
proxy_set_header X-Client-IP $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}

打赏

Leave a comment

您的电子邮箱地址不会被公开。