Closed Weedonfenng closed 4 years ago
`- (void)configSession{ MQTTCFSocketTransport *transport = [[MQTTCFSocketTransport alloc] init]; transport.host = self.mqttModel.mqttHost;//"192.168.207.139" transport.port = self.mqttModel.mqttPort;//1884
MQTTSession *session = [[MQTTSession alloc] init]; session.transport = transport; session.userName = self.mqttModel.userName;//000220849677363831294304 session.password = self.mqttModel.password;//3efbcf2261fb45b7940c40b313191ed3 session.delegate = self; [session connectWithConnectHandler:^(NSError *error) { if (!error) { [session subscribeToTopic:self.mqttModel.groupTopic atLevel:2 subscribeHandler:^(NSError *error, NSArray<NSNumber *> *gQoss) { if (error) { NSLog(@"Subscription failed %@", error.localizedDescription); } else { NSLog(@"Subscription sucessfull! Granted Qos: %@", gQoss); } }]; [session subscribeToTopic:self.mqttModel.clientTopic atLevel:2 subscribeHandler:^(NSError *error, NSArray<NSNumber *> *gQoss) { if (error) { NSLog(@"Subscription failed %@", error.localizedDescription); } else { NSLog(@"Subscription sucessfull! Granted Qos: %@", gQoss); } }]; } }];
}`
the delegate API connected: was called,but the subscribeHandler can't tell me whether the session subscribeToTopic result successful or failed,the console log bellow: 2019-04-10 14:48:37.731302+0800 MQQTDemo[6322:5674594] [MQTTSession] init 2019-04-10 14:48:37.731517+0800 MQQTDemo[6322:5674594] [MQTTSession] connectWithConnectHandler:0x16d372450 2019-04-10 14:48:37.731586+0800 MQQTDemo[6322:5674594] [MQTTSession] connecting 2019-04-10 14:48:37.731627+0800 MQQTDemo[6322:5674594] [MQTTCoreDataPersistence] deleteAllFlowsForClientId MQTTClient731425 2019-04-10 14:48:37.733249+0800 MQQTDemo[6322:5674594] [MQTTPersistence] Persistent store: /var/mobile/Containers/Data/Application/06B05907-06ED-45A1-9004-D079319E8478/Documents/MQTTClient 2019-04-10 14:48:37.738192+0800 MQQTDemo[6322:5674594] [MQTTCFSocketTransport] open 2019-04-10 14:48:37.739442+0800 MQQTDemo[6322:5674594] [MQTTCFSocketEncoder] setState 0/0 2019-04-10 14:48:37.774184+0800 MQQTDemo[6322:5674594] [MQTTCFSocketDecoder] NSStreamEventOpenCompleted 2019-04-10 14:48:37.774251+0800 MQQTDemo[6322:5674594] [MQTTCFSocketEncoder] NSStreamEventOpenCompleted 2019-04-10 14:48:37.774282+0800 MQQTDemo[6322:5674594] [MQTTCFSocketEncoder] NSStreamEventHasSpaceAvailable 2019-04-10 14:48:37.774301+0800 MQQTDemo[6322:5674594] [MQTTCFSocketEncoder] setState 0/1 2019-04-10 14:48:37.774327+0800 MQQTDemo[6322:5674594] [MQTTSession] mqttTransportDidOpen 2019-04-10 14:48:37.774340+0800 MQQTDemo[6322:5674594] [MQTTSession] sending CONNECT 2019-04-10 14:48:37.774718+0800 MQQTDemo[6322:5674594] [MQTTMessage] wireFormat(90)=<10580004 4d515454 04c2003c 00104d51 5454436c 69656e74 37333134 32350018 30303032 32303834 39363737 33363338 33313239 34333034 00203763 61316565 63646331 38383462 33366164 33653832 34306563 36376666 6266>... 2019-04-10 14:48:37.774759+0800 HorseMan[6322:5674594] [MQTTSession] mqttTransport send 2019-04-10 14:48:37.774861+0800 MQQTDemo[6322:5674594] [MQTTCFSocketEncoder] buffer to write (90)=<10580004 4d515454 04c2003c 00104d51 5454436c 69656e74 37333134 32350018 30303032 32303834 39363737 33363338 33313239 34333034 00203763 61316565 63646331 38383462 33366164 33653832 34306563 36376666 6266>... 2019-04-10 14:48:37.775166+0800 MQQTDemo[6322:5674594] [MQTTCFSocketEncoder] NSStreamEventHasSpaceAvailable 2019-04-10 14:48:37.777889+0800 MQQTDemo[6322:5674594] [MQTTCFSocketDecoder] NSStreamEventHasBytesAvailable 2019-04-10 14:48:37.778045+0800 MQQTDemo[6322:5674594] [MQTTCFSocketDecoder] received (4)=<20020000>... 2019-04-10 14:48:37.778076+0800 MQQTDemo[6322:5674594] [MQTTSession] mqttTransport didReceiveMessage 2019-04-10 14:48:37.778191+0800 MQQTDemo[6322:5674594] [MQTTDecoder] #streams=1 2019-04-10 14:48:37.778334+0800 MQQTDemo[6322:5674594] [MQTTDecoder] NSStreamEventOpenCompleted 2019-04-10 14:48:37.778397+0800 MQQTDemo[6322:5674594] [MQTTDecoder] NSStreamEventHasBytesAvailable 2019-04-10 14:48:37.778502+0800 MQQTDemo[6322:5674594] [MQTTDecoder] fixedHeader=0x20 2019-04-10 14:48:37.778553+0800 MQQTDemo[6322:5674594] [MQTTDecoder] digit=0x02 0x02 0 1 2019-04-10 14:48:37.778576+0800 MQQTDemo[6322:5674594] [MQTTDecoder] remainingLength=2 2019-04-10 14:48:37.778658+0800 MQQTDemo[6322:5674594] [MQTTDecoder] read 2 2 2019-04-10 14:48:37.778728+0800 MQQTDemo[6322:5674594] [MQTTDecoder] received (4)=<20020000>... 2019-04-10 14:48:37.779012+0800 MQQTDemo[6322:5674594] [MQTTSession] checkDup MQTTClient731425 @1554878918 2019-04-10 14:48:41.028894+0800 MQQTDemo[6322:5674594] [MQTTSession] subscribeToTopics:{ "neworder/WQJ6S" = 2; }] 2019-04-10 14:48:41.028986+0800 MQQTDemo[6322:5674594] nextMsgId synchronizing 2019-04-10 14:48:41.029012+0800 MQQTDemo[6322:5674594] nextMsgId synchronized 2019-04-10 14:48:41.029037+0800 MQQTDemo[6322:5674594] flowforClientId requestingPerform 2019-04-10 14:48:41.029065+0800 MQQTDemo[6322:5674594] flowforClientId performing 2019-04-10 14:48:41.029267+0800 MQQTDemo[6322:5674594] flowforClientId performed 2019-04-10 14:48:41.029293+0800 MQQTDemo[6322:5674594] nextMsgId synchronized done 2019-04-10 14:48:41.029401+0800 MQQTDemo[6322:5674594] [MQTTMessage] wireFormat(21)=<82130002 000e6e65 776f7264 65722f57 514a3653 02>... 2019-04-10 14:48:41.029435+0800 MQQTDemo[6322:5674594] [MQTTSession] mqttTransport send 2019-04-10 14:48:41.029492+0800 MQQTDemo[6322:5674594] [MQTTCFSocketEncoder] buffer to write (21)=<82130002 000e6e65 776f7264 65722f57 514a3653 02>... 2019-04-10 14:48:41.029733+0800 MQQTDemo[6322:5674594] [MQTTSession] subscribeToTopics:{ 000220849677363831294304 = 2; }] 2019-04-10 14:48:41.034347+0800 MQQTDemo[6322:5674594] nextMsgId synchronizing 2019-04-10 14:48:41.034508+0800 MQQTDemo[6322:5674594] nextMsgId synchronized 2019-04-10 14:48:41.034533+0800 MQQTDemo[6322:5674594] flowforClientId requestingPerform 2019-04-10 14:48:41.034554+0800 MQQTDemo[6322:5674594] flowforClientId performing 2019-04-10 14:48:41.034704+0800 MQQTDemo[6322:5674594] flowforClientId performed 2019-04-10 14:48:41.034722+0800 MQQTDemo[6322:5674594] nextMsgId synchronized done 2019-04-10 14:48:41.034823+0800 MQQTDemo[6322:5674594] [MQTTMessage] wireFormat(31)=<821d0003 00183030 30323230 38343936 37373336 33383331 32393433 303402>... 2019-04-10 14:48:41.034849+0800 MQQTDemo[6322:5674594] [MQTTSession] mqttTransport send 2019-04-10 14:48:41.034901+0800 MQQTDemo[6322:5674594] [MQTTCFSocketEncoder] buffer to write (31)=<821d0003 00183030 30323230 38343936 37373336 33383331 32393433 303402>...
2019-04-10 14:48:41.036644+0800 MQQTDemo[6322:5674594] [MQTTCFSocketTransport] close
Can you please provide more details about your issue?
`- (void)configSession{ MQTTCFSocketTransport *transport = [[MQTTCFSocketTransport alloc] init]; transport.host = self.mqttModel.mqttHost;//"192.168.207.139" transport.port = self.mqttModel.mqttPort;//1884
}`
the delegate API connected: was called,but the subscribeHandler can't tell me whether the session subscribeToTopic result successful or failed,the console log bellow: 2019-04-10 14:48:37.731302+0800 MQQTDemo[6322:5674594] [MQTTSession] init 2019-04-10 14:48:37.731517+0800 MQQTDemo[6322:5674594] [MQTTSession] connectWithConnectHandler:0x16d372450 2019-04-10 14:48:37.731586+0800 MQQTDemo[6322:5674594] [MQTTSession] connecting 2019-04-10 14:48:37.731627+0800 MQQTDemo[6322:5674594] [MQTTCoreDataPersistence] deleteAllFlowsForClientId MQTTClient731425 2019-04-10 14:48:37.733249+0800 MQQTDemo[6322:5674594] [MQTTPersistence] Persistent store: /var/mobile/Containers/Data/Application/06B05907-06ED-45A1-9004-D079319E8478/Documents/MQTTClient 2019-04-10 14:48:37.738192+0800 MQQTDemo[6322:5674594] [MQTTCFSocketTransport] open 2019-04-10 14:48:37.739442+0800 MQQTDemo[6322:5674594] [MQTTCFSocketEncoder] setState 0/0 2019-04-10 14:48:37.774184+0800 MQQTDemo[6322:5674594] [MQTTCFSocketDecoder] NSStreamEventOpenCompleted 2019-04-10 14:48:37.774251+0800 MQQTDemo[6322:5674594] [MQTTCFSocketEncoder] NSStreamEventOpenCompleted 2019-04-10 14:48:37.774282+0800 MQQTDemo[6322:5674594] [MQTTCFSocketEncoder] NSStreamEventHasSpaceAvailable 2019-04-10 14:48:37.774301+0800 MQQTDemo[6322:5674594] [MQTTCFSocketEncoder] setState 0/1 2019-04-10 14:48:37.774327+0800 MQQTDemo[6322:5674594] [MQTTSession] mqttTransportDidOpen 2019-04-10 14:48:37.774340+0800 MQQTDemo[6322:5674594] [MQTTSession] sending CONNECT 2019-04-10 14:48:37.774718+0800 MQQTDemo[6322:5674594] [MQTTMessage] wireFormat(90)=<10580004 4d515454 04c2003c 00104d51 5454436c 69656e74 37333134 32350018 30303032 32303834 39363737 33363338 33313239 34333034 00203763 61316565 63646331 38383462 33366164 33653832 34306563 36376666 6266>... 2019-04-10 14:48:37.774759+0800 HorseMan[6322:5674594] [MQTTSession] mqttTransport send 2019-04-10 14:48:37.774861+0800 MQQTDemo[6322:5674594] [MQTTCFSocketEncoder] buffer to write (90)=<10580004 4d515454 04c2003c 00104d51 5454436c 69656e74 37333134 32350018 30303032 32303834 39363737 33363338 33313239 34333034 00203763 61316565 63646331 38383462 33366164 33653832 34306563 36376666 6266>... 2019-04-10 14:48:37.775166+0800 MQQTDemo[6322:5674594] [MQTTCFSocketEncoder] NSStreamEventHasSpaceAvailable 2019-04-10 14:48:37.777889+0800 MQQTDemo[6322:5674594] [MQTTCFSocketDecoder] NSStreamEventHasBytesAvailable 2019-04-10 14:48:37.778045+0800 MQQTDemo[6322:5674594] [MQTTCFSocketDecoder] received (4)=<20020000>... 2019-04-10 14:48:37.778076+0800 MQQTDemo[6322:5674594] [MQTTSession] mqttTransport didReceiveMessage 2019-04-10 14:48:37.778191+0800 MQQTDemo[6322:5674594] [MQTTDecoder] #streams=1 2019-04-10 14:48:37.778334+0800 MQQTDemo[6322:5674594] [MQTTDecoder] NSStreamEventOpenCompleted 2019-04-10 14:48:37.778397+0800 MQQTDemo[6322:5674594] [MQTTDecoder] NSStreamEventHasBytesAvailable 2019-04-10 14:48:37.778502+0800 MQQTDemo[6322:5674594] [MQTTDecoder] fixedHeader=0x20 2019-04-10 14:48:37.778553+0800 MQQTDemo[6322:5674594] [MQTTDecoder] digit=0x02 0x02 0 1 2019-04-10 14:48:37.778576+0800 MQQTDemo[6322:5674594] [MQTTDecoder] remainingLength=2 2019-04-10 14:48:37.778658+0800 MQQTDemo[6322:5674594] [MQTTDecoder] read 2 2 2019-04-10 14:48:37.778728+0800 MQQTDemo[6322:5674594] [MQTTDecoder] received (4)=<20020000>... 2019-04-10 14:48:37.779012+0800 MQQTDemo[6322:5674594] [MQTTSession] checkDup MQTTClient731425 @1554878918 2019-04-10 14:48:41.028894+0800 MQQTDemo[6322:5674594] [MQTTSession] subscribeToTopics:{ "neworder/WQJ6S" = 2; }] 2019-04-10 14:48:41.028986+0800 MQQTDemo[6322:5674594] nextMsgId synchronizing 2019-04-10 14:48:41.029012+0800 MQQTDemo[6322:5674594] nextMsgId synchronized 2019-04-10 14:48:41.029037+0800 MQQTDemo[6322:5674594] flowforClientId requestingPerform 2019-04-10 14:48:41.029065+0800 MQQTDemo[6322:5674594] flowforClientId performing 2019-04-10 14:48:41.029267+0800 MQQTDemo[6322:5674594] flowforClientId performed 2019-04-10 14:48:41.029293+0800 MQQTDemo[6322:5674594] nextMsgId synchronized done 2019-04-10 14:48:41.029401+0800 MQQTDemo[6322:5674594] [MQTTMessage] wireFormat(21)=<82130002 000e6e65 776f7264 65722f57 514a3653 02>... 2019-04-10 14:48:41.029435+0800 MQQTDemo[6322:5674594] [MQTTSession] mqttTransport send 2019-04-10 14:48:41.029492+0800 MQQTDemo[6322:5674594] [MQTTCFSocketEncoder] buffer to write (21)=<82130002 000e6e65 776f7264 65722f57 514a3653 02>... 2019-04-10 14:48:41.029733+0800 MQQTDemo[6322:5674594] [MQTTSession] subscribeToTopics:{ 000220849677363831294304 = 2; }] 2019-04-10 14:48:41.034347+0800 MQQTDemo[6322:5674594] nextMsgId synchronizing 2019-04-10 14:48:41.034508+0800 MQQTDemo[6322:5674594] nextMsgId synchronized 2019-04-10 14:48:41.034533+0800 MQQTDemo[6322:5674594] flowforClientId requestingPerform 2019-04-10 14:48:41.034554+0800 MQQTDemo[6322:5674594] flowforClientId performing 2019-04-10 14:48:41.034704+0800 MQQTDemo[6322:5674594] flowforClientId performed 2019-04-10 14:48:41.034722+0800 MQQTDemo[6322:5674594] nextMsgId synchronized done 2019-04-10 14:48:41.034823+0800 MQQTDemo[6322:5674594] [MQTTMessage] wireFormat(31)=<821d0003 00183030 30323230 38343936 37373336 33383331 32393433 303402>... 2019-04-10 14:48:41.034849+0800 MQQTDemo[6322:5674594] [MQTTSession] mqttTransport send 2019-04-10 14:48:41.034901+0800 MQQTDemo[6322:5674594] [MQTTCFSocketEncoder] buffer to write (31)=<821d0003 00183030 30323230 38343936 37373336 33383331 32393433 303402>...
2019-04-10 14:48:41.036644+0800 MQQTDemo[6322:5674594] [MQTTCFSocketTransport] close