emqx / CocoaMQTT

MQTT 5.0 client library for iOS and macOS written in Swift
https://www.emqx.com/en
Other
1.59k stars 418 forks source link

Error Domain=NSPOSIXErrorDomain Code=57 "Socket is not connected #330

Open amitsanvedi opened 4 years ago

amitsanvedi commented 4 years ago

Hi I am newer in MQTT and used your library and want to make connection with following server URL:Ws://trialadm.satalarm.com/mqtt I am using below code but getting error Response Error : mqttDidDisconnectOptional(Error Domain=NSPOSIXErrorDomain Code=57 "Socket is not connected" UserInfo={NSErrorFailingURLStringKey=http://trialadm.satalarm.com:8000/mqtt, NSErrorFailingURLKey=http://trialadm.satalarm.com:8000/mqtt})

Code : let clientID = "CocoaMQTT-" + String(ProcessInfo().processIdentifier) let websocket = CocoaMQTTWebSocket(uri: "/mqtt") let mqtt = CocoaMQTT(clientID: clientID, host: "trialadm.satalarm.com", port:8000, socket: websocket) mqtt.username = "nit" mqtt.password = "VR4xZCwPoBVAoxaHCI1R" mqtt.keepAlive = 60 mqtt.delegate = self // mqtt.allowUntrustCACertificate = true //mqtt.enableSSL = false mqtt.willMessage = CocoaMQTTMessage(topic: "testtopic/1212", string: "Testing rg") mqtt.willMessage?.retained = true let connect = mqtt.connect()

There are 2 things first I am not able to connect and second thing the url which is showing in response is having http url as it should Ws url. Please let me know whats wrong with this.

Raonshi commented 9 months ago

Same Problem