Closed ssladn closed 5 years ago
You need to use a valid protocol for your broker: Nowadays this is probably MQTTProtocolVersion311
Snippet from MQTTMessage.h
/**
Enumeration of MQTT protocol version
*/
typedef NS_ENUM(UInt8, MQTTProtocolVersion) {
MQTTProtocolVersion0 = 0,
MQTTProtocolVersion31 = 3,
MQTTProtocolVersion311 = 4,
MQTTProtocolVersion50 = 5
};
but add MQTTProtocolVersion311 problem still
@ssladn problem have saved ?
is this issue resolved? I am getting same issue.
Please check it out my log :
2019-03-08 12:19:20.330493+0530 IotLearning1[3426:892281] [MQTTSession] init 2019-03-08 12:19:20.567553+0530 IotLearning1[3426:892281] [MQTTSessionLegacy] initWithClientId:abc1 2019-03-08 12:19:20.568257+0530 IotLearning1[3426:892281] [MQTTSession] init 2019-03-08 12:19:20.568622+0530 IotLearning1[3426:892281] [MQTTSession] connectWithConnectHandler:0x101798af0 2019-03-08 12:19:20.570102+0530 IotLearning1[3426:892281] [MQTTSession] connecting 2019-03-08 12:19:20.622470+0530 IotLearning1[3426:892281] [MQTTPersistence] Persistent store: /var/mobile/Containers/Data/Application/5876D8DB-4472-46A1-8F7C-D6EA20EF2CC8/Documents/MQTTClient 2019-03-08 12:19:20.647487+0530 IotLearning1[3426:892281] [MQTTCFSocketTransport] open 2019-03-08 12:19:20.655309+0530 IotLearning1[3426:892281] [MQTTCFSocketEncoder] setState 0/0 2019-03-08 12:19:21.211912+0530 IotLearning1[3426:892281] [MQTTCFSocketDecoder] NSStreamEventOpenCompleted 2019-03-08 12:19:21.212037+0530 IotLearning1[3426:892281] [MQTTCFSocketEncoder] NSStreamEventOpenCompleted 2019-03-08 12:19:21.212169+0530 IotLearning1[3426:892281] [MQTTCFSocketEncoder] NSStreamEventHasSpaceAvailable 2019-03-08 12:19:21.212215+0530 IotLearning1[3426:892281] [MQTTCFSocketEncoder] setState 0/1 2019-03-08 12:19:21.212258+0530 IotLearning1[3426:892281] [MQTTSession] mqttTransportDidOpen 2019-03-08 12:19:21.212394+0530 IotLearning1[3426:892281] [MQTTSession] sending CONNECT 2019-03-08 12:19:21.214132+0530 IotLearning1[3426:892281] [MQTTMessage] wireFormat(58)=<10380004 4d515454 04c00028 00046162 63310012 4f47396b 6a433253 5a466145 446b6b4a 434f0012 77475263 54426345 46524266 4c646650 346c>... 2019-03-08 12:19:21.214349+0530 IotLearning1[3426:892281] [MQTTSession] mqttTransport send 2019-03-08 12:19:21.215206+0530 IotLearning1[3426:892281] [MQTTCFSocketEncoder] buffer to write (58)=<10380004 4d515454 04c00028 00046162 63310012 4f47396b 6a433253 5a466145 446b6b4a 434f0012 77475263 54426345 46524266 4c646650 346c>... 2019-03-08 12:19:21.216047+0530 IotLearning1[3426:892281] [MQTTCFSocketEncoder] NSStreamEventHasSpaceAvailable 2019-03-08 12:19:21.554214+0530 IotLearning1[3426:892281] [MQTTCFSocketDecoder] NSStreamEventHasBytesAvailable 2019-03-08 12:19:21.554780+0530 IotLearning1[3426:892281] [MQTTCFSocketDecoder] received (4)=<20020100>... 2019-03-08 12:19:21.554911+0530 IotLearning1[3426:892281] [MQTTSession] mqttTransport didReceiveMessage 2019-03-08 12:19:21.555225+0530 IotLearning1[3426:892281] [MQTTDecoder] #streams=1 2019-03-08 12:19:21.561904+0530 IotLearning1[3426:892482] [MQTTDecoder] NSStreamEventOpenCompleted 2019-03-08 12:19:21.563069+0530 IotLearning1[3426:892482] [MQTTDecoder] NSStreamEventHasBytesAvailable 2019-03-08 12:19:21.565067+0530 IotLearning1[3426:892482] [MQTTDecoder] fixedHeader=0x20 2019-03-08 12:19:21.566168+0530 IotLearning1[3426:892479] [MQTTDecoder] NSStreamEventHasBytesAvailable 2019-03-08 12:19:21.567858+0530 IotLearning1[3426:892482] [MQTTDecoder] digit=0x02 0x02 0 1 2019-03-08 12:19:21.569000+0530 IotLearning1[3426:892482] [MQTTDecoder] remainingLength=2 2019-03-08 12:19:21.570309+0530 IotLearning1[3426:892479] [MQTTDecoder] digit=0x01 0x01 2 1 2019-03-08 12:19:21.572292+0530 IotLearning1[3426:892479] [MQTTDecoder] remainingLength=3 2019-03-08 12:19:21.573719+0530 IotLearning1[3426:892482] [MQTTDecoder] read 3 0 2019-03-08 12:19:21.574974+0530 IotLearning1[3426:892482] [MQTTDecoder] oops received (3)=<200201>... 2019-03-08 12:19:21.575961+0530 IotLearning1[3426:892479] [MQTTDecoder] read 3 1 2019-03-08 12:19:21.577014+0530 IotLearning1[3426:892479] [MQTTDecoder] oops received (4)=<20020100>... 2019-03-08 12:19:21.578154+0530 IotLearning1[3426:892479] [MQTTDecoder] NSStreamEventEndEncountered 2019-03-08 12:20:00.079221+0530 IotLearning1[3426:892281] Status bar could not find cached time string image. Rendering in-process. 2019-03-08 12:20:21.439245+0530 IotLearning1[3426:892281] [MQTTCFSocketDecoder] NSStreamEventHasBytesAvailable 2019-03-08 12:20:21.440014+0530 IotLearning1[3426:892281] [MQTTCFSocketDecoder] received (0)=<>... 2019-03-08 12:20:21.440148+0530 IotLearning1[3426:892281] [MQTTSession] mqttTransport didReceiveMessage 2019-03-08 12:20:21.440342+0530 IotLearning1[3426:892281] [MQTTDecoder] #streams=1 2019-03-08 12:20:21.440843+0530 IotLearning1[3426:892281] [MQTTCFSocketDecoder] NSStreamEventEndEncountered 2019-03-08 12:20:21.441080+0530 IotLearning1[3426:892281] [MQTTSession] mqttTransport mqttTransportDidClose 2019-03-08 12:20:21.443039+0530 IotLearning1[3426:892281] [MQTTSession] closeInternal 2019-03-08 12:20:21.443215+0530 IotLearning1[3426:892281] [MQTTCFSocketTransport] close connection completed with status Optional(Error Domain=MQTT Code=-8 "Server has closed connection without connack." UserInfo={NSLocalizedDescription=Server has closed connection without connack.})
@ckrey Will you please look into this?
I am closing this issue as there was no activity for some time. Feel free to reopen and add more info.
Hello, When i use the v0.13.1 MQTTSessionManager to connect service ,it was error for this error:Error Domain=MQTT Code=-8 "Server has closed connection without connack." UserInfo={NSLocalizedDescription=Server has closed connection without connack.} code: [m.mqttM connectTo:host port:port tls:isTls keepalive:keepLive clean:isClean auth:isAuth user:name pass:pass will:false willTopic:topic willMsg:data willQos:qos willRetainFlag:retainFlag withClientId:[[NSUUID UUID] UUIDString] securityPolicy:nil certificates:nil protocolLevel:MQTTProtocolVersion0 connectHandler:^(NSError *error) { NSLog(@"error:%@",error); }];
But i used the V0.10.1 it was successfully. code: m.mqttM = [[MQTTSessionManager alloc] init]; m.mqttM.delegate = m; [m.mqttM connectTo:host port:port tls:isTls keepalive:keepLive clean:isClean auth:isAuth user:name pass:pass willTopic:topic will:data willQos:qos willRetainFlag:retainFlag withClientId:[[NSUUID UUID] UUIDString]];
so,i don't know what wrong with my code. Please help me.