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

publish failed #395

Open hubfresher opened 2 years ago

hubfresher commented 2 years ago

when I call like this: mqtt.publish(CocoaMQTTMessage(topic: connectTopicString, payload: [10], qos: .qos1, retained: true)) , I get error as follows: mqttDidDisconnect:Optional(Error Domain=GCDAsyncSocketErrorDomain Code=7 "Socket closed by remote peer" UserInfo={NSLocalizedDescription=Socket closed by remote peer}

anyone meet the problem?

leeway1208 commented 2 years ago

Hi, try this :

//CocoaMQTTMessage(topic: connectTopicString, string: "your message", qos: .qos1, retained: true)

mqtt.publish(CocoaMQTTMessage(topic: connectTopicString, string: "your message", qos: .qos1, retained: true))