novastone-media / MQTT-Client-Framework

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

Connection Closed by broker #447

Closed vipulsinghania closed 6 years ago

vipulsinghania commented 6 years ago

Hi Below is my code for establishing mqtt connection over websocket. For code below i am getting Connection Closed by broker and then connection is closed. Kindly help.

var sessionManager = MQTTSessionManager()
var serieID:Int = 265

sessionManager.connect(to: "apidev.cloudtimer.nl", port: 1883, tls: false, keepalive: 60, clean: true, auth: false, user: nil, pass: nil, will: false, willTopic: nil, willMsg: nil, willQos: .atMostOnce, willRetainFlag: true, withClientId: nil ) sessionManager.delegate = self sessionManager.session.protocolLevel = .version311 sessionManager.session.delegate = self

     let channel = String(format:"serie_%d",self.serieID)
     sessionManager.session.subscribe(toTopic: channel, at: .atLeastOnce)
jcavar commented 6 years ago

Unfortunately websocket transport is not supported for MQTTSessionManager. You will need to manually create MQTTSession and set transport property to instance of MQTTWebsocketTransport.