Closed sonhd92 closed 1 year ago
@sonhd92 hi, try these codes
let clientID = "CocoaMQTT-\(animal!)-" + String(ProcessInfo().processIdentifier)
let websocket = CocoaMQTTWebSocket(uri: "/mqtt")
mqtt = CocoaMQTT(clientID: clientID, host: "cpl-emqx-socket.staging-bitcastle.work", port: 8083, socket: websocket)
mqtt!.username = ""
mqtt!.password = ""
mqtt!.willMessage = CocoaMQTTMessage(topic: "/will", string: "dieout")
mqtt!.keepAlive = 60
mqtt!.delegate = self
mqtt!.enableSSL = true
@sonhd92 did you find any workaround? I have the same problem.
@sonhd92 did you find any workaround? I have the same problem.
I use the solution of @leeway1208 above and it's worked for me
Hi, I'm facing this issue when using CocoaMQTT/Websocket by doing
pod 'CocoaMQTT/WebSockets', '1.3.0-rc.2'
to connect to my host at this url:wss://cpl-emqx-socket.staging-bitcastle.work:8083/mqtt
And this is what console log show for me:
2021-11-01 14:09:23.375234+0700 BitcastleApp[13709:570825] Task <ECC86E98-32B4-4C58-85D1-34BB7FC3C881>.<1> finished with error [-1003] Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo={NSErrorFailingURLStringKey=https://wss//dev-cpl-socket.staging-bitcastle.work:8083/mqtt, NSErrorFailingURLKey=https://wss//dev-cpl-socket.staging-bitcastle.work:8083/mqtt, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalWebSocketTask <ECC86E98-32B4-4C58-85D1-34BB7FC3C881>.<1>" ), _NSURLErrorFailingURLSessionTaskErrorKey=LocalWebSocketTask <ECC86E98-32B4-4C58-85D1-34BB7FC3C881>.<1>, NSLocalizedDescription=A server with the specified hostname could not be found.}
Here is my code, why the url still has http/https before wss? Can someone explain for me where's wrong in my code: