novastone-media / MQTT-Client-Framework

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

Set up the willMsg is nil in the latest version, #539

Open holidayMi opened 5 years ago

holidayMi commented 5 years ago

Hello, when I set willMsg as nil in the latest version (0.15.2), I can't connect to the server, but it is clearly said in the parameter description of the method that it can be empty, please help me explain how to set this parameter on earth. Here is the code that cannot be connected

[self.manager connectTo:@"xxxhost" port:1883 tls:FALSE keepalive:60 clean:true auth:false user:nil pass:nil will:[@"offline" dataUsingEncoding:NSUTF8StringEncoding] willTopic:@"test1" willMsg:nil willQos:MQTTQosLevelExactlyOnce willRetainFlag:FALSE withClientId:@"123" securityPolicy:nil certificates:nil protocolLevel:MQTTProtocolVersion311 connectHandler:^(NSError *error) {
            //
        }];

Here is the code to connect to

[self.manager connectTo:self.mqttSettings[@"host"] port:[self.mqttSettings[@"port"] intValue] tls:[self.mqttSettings[@"tls"] boolValue] keepalive:60 clean:true auth:false user:nil pass:nil will:[@"offline" dataUsingEncoding:NSUTF8StringEncoding] willTopic:@"test" willMsg:[@"joins chat" dataUsingEncoding:NSUTF8StringEncoding] willQos:MQTTQosLevelAtMostOnce willRetainFlag:FALSE withClientId:nil securityPolicy:nil certificates:nil protocolLevel:MQTTProtocolVersion311 connectHandler:^(NSError *error) {
        }];

By the way, I think it's good to provide the latest version in the demo This is my first time to ask a question here and I hope to get your reply

jcavar commented 4 years ago

Hello, We will need more details to understand your issue. Does it connect with will, do you have logs, what broker are you connecting to, ...

jcavar commented 4 years ago

Ok, I think I see a problem:

You need to pass will:NO instead of encoded data.