CocoaMQTT icon indicating copy to clipboard operation
CocoaMQTT copied to clipboard

Is it possible to connect over wss?

Open nathanmrtns opened this issue 7 years ago • 8 comments

I´m trying to connect with the following code:

        let clientID = "CocoaMQTT-" + String(ProcessInfo().processIdentifier)
       // myHost: wss://myserver.test:9001
        let mqtt = CocoaMQTT(clie.ntID: clientID, host: "myserver.test", port: 9001)
        mqtt.keepAlive = 10000
        mqtt.username = "username"
        mqtt.password = "password"
        mqtt.enableSSL = true
        mqtt.delegate = self
        mqtt.connect()
        mqtt.autoReconnect = true

I get the error: Error Domain=GCDAsyncSocketErrorDomain Code=7 "Socket closed by remote peer" UserInfo={NSLocalizedDescription=Socket closed by remote peer}

Does CocoaMQTT support wss or only tcp?

nathanmrtns avatar Dec 07 '17 14:12 nathanmrtns

@NathanMrtns The library still not supports MQTT over Websocket.

emqplus avatar Dec 16 '17 09:12 emqplus

Is there any library support MQTT over Websocket ? @emqplus

yusufonderd avatar May 07 '18 11:05 yusufonderd

@yusufonderd Do you want to connect to a MQTT broker in a WebView? If so you could use mqttws31.js. Or you could try MQTT-Client-Framework.

terry-xiaoyu avatar May 07 '18 12:05 terry-xiaoyu

@terry-xiaoyu I tried MQTT-Client-Framework but it didn't work. You can look my issue from link : https://github.com/novastone-media/MQTT-Client-Framework/issues/458. How can I use MQTT broker in WebView ? I don't understand. Can you help me ?

yusufonderd avatar May 08 '18 12:05 yusufonderd

Hey @yusufonderd I replied your post there. Check if it works

nathanmrtns avatar May 08 '18 12:05 nathanmrtns

@NathanMrtns unfortunately it doesn't work.

yusufonderd avatar May 08 '18 12:05 yusufonderd

Now support WSS? @HJianBo

chancyWu avatar Nov 25 '19 08:11 chancyWu

Got answer from https://github.com/emqx/CocoaMQTT/issues/174. seems not support WSS now. Pls let me know if support now.

chancyWu avatar Nov 25 '19 08:11 chancyWu