Open chentianci123 opened 4 years ago
希望可以帮我解决这个问题,谢谢
现在又遇到一个问题,Error:AMQJS0013E Invalid argument mqtt://192.168.22.149:1883 for host
现在又遇到一个问题,Error:AMQJS0013E Invalid argument mqtt://192.168.22.149:1883 for host
解决了吗 老铁
let username = "xxx";
let passWord = "xxx";
let hostname = "ws://xxx.xxx.2.150/ws"; //替换成的你百度实例地址
let port = "15675"; //使用WSS协议的接口地址
Fri, 05 Mar 2021 05:59:42 GMT - ERROR - Failed to connect. [Error Message: AMQJS0007E Socket error:undefined.] 有人遇到这个问题吗?
This Library uses web-sockets. Your Port should be of the web-socket, not TCP port. E.g: https://developpaper.com/using-websocket-to-connect-to-mqtt-server/
In the link above you see that for this broker: Broker: broker.emqx.io
//..................................................
TCP Port: 1883 //..................................................
Websocket Port: 8083
I changed to this web-socket port . It fixed the error.
代码: import { AsyncStorage }from'react-native'; import init from 'react_native_mqtt'; init({ size: 10000, storageBackend: AsyncStorage, defaultExpires: 1000 3600 24, enableCache: true, reconnect: true, sync: {} }); //第一步:创建 // 地址,端口,路径(这么写就行了),connectId(随便写) :地址和端口,都是后台给,或者你自己弄个mqtt的服务 //完整路径为:mqtt://192.168.22.149:1883 let client = new Paho.MQTT.Client('192.168.22.149',1883,'/mqtt','aaa')
版本: "react": "16.9.0", "react-native": "0.61.1", "react_native_mqtt": "^1.3.1"
报错信息: 失败 {"errorCode":7,"errorMessage":"AMQJS0007E Socket error:undefined.","invocationContext":undefined}