novastone-media / MQTT-Client-Framework

iOS, macOS, tvOS native ObjectiveC MQTT Client Framework
Other
1.84k stars 463 forks source link

MQTTWebsocketTransport auto connect is not working #534

Closed RajaReddyiOS closed 4 years ago

RajaReddyiOS commented 5 years ago

MQTTWebsocketTransport auto connect is not working once network is back

Using this format: let session = MQTTSession(clientId: "ClientID", userName: "userName", password: "***", keepAlive: UInt16(MQTTClientServices.KEEP_ALIVE_TIME), connect: nil, cleanSession: true, will: false, willTopic: nil, willMsg: nil, willQoS: MQTTQosLevel.atLeastOnce, willRetainFlag: true, protocolLevel: MQTTProtocolVersion.version311.rawValue, queue: DispatchQueue.main, securityPolicy: nil, certificates: nil)

    let transport = MQTTWebsocketTransport()
    let url = URL(string: "wss://host:port/mqtt")
    transport.url = url
    session?.transport = transport        
    self.session = session
    self.session?.delegate = self        
    self.session!.connect { (error) in
        print("error message: \(String(describing: error))")
    },

Thanks in advance

jcavar commented 5 years ago

MQTTWebSocketTransport on its own doesn't implement auto reconnect. If you need that behaviour you can implement that in your application.