{"action":"created","issue":{"url":"https://api.github.com/repos/flightonary/Moscapsule/issues/55","repository_url":"https://api.github.com/repos/flightonary/Moscapsule","labels_url":"https://api.github.com/repos/flightonary/Moscapsule/issues/55/labels{/name}","comments_url":"https://api.github.com/repos/flightonary/Moscapsule/issues/55/comments","events_url":"https://api.github.com/repos/flightonary/Moscapsule/issues/55/events","html_url":"https://github.com/flightonary/Moscapsule/issues/55","id":215751988,"number":55,"title":"Can not receive messages ","user":{"login":"vladimirjankov","id":26569055,"avatar_url":"https://avatars2.githubusercontent.com/u/26569055?v=4","gravatar_id":"","url":"https://api.github.com/users/vladimirjankov","html_url":"https://github.com/vladimirjankov","followers_url":"https://api.github.com/users/vladimirjankov/followers","following_url":"https://api.github.com/users/vladimirjankov/following{/other_user}","gists_url":"https://api.github.com/users/vladimirjankov/gists{/gist_id}","starred_url":"https://api.github.com/users/vladimirjankov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vladimirjankov/subscriptions","organizations_url":"https://api.github.com/users/vladimirjankov/orgs","repos_url":"https://api.github.com/users/vladimirjankov/repos","events_url":"https://api.github.com/users/vladimirjankov/events{/privacy}","received_events_url":"https://api.github.com/users/vladimirjankov/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":15,"created_at":"2017-03-21T14:09:25Z","updated_at":"2018-05-17T01:09:11Z","closed_at":null,"author_association":"NONE","body":"  var mqttClient: MQTTClient? = nil\r\n    let mqttConfig = MQTTConfig(clientId: \"Sasa\", host: \"192.168.0.11\", port: 1883, keepAlive: 60)\r\n    override func viewDidLoad() {\r\n        super.viewDidLoad()\r\n        mqttClient = MQTT.newConnection(mqttConfig)\r\n\r\n        print( \"\\(mqttClient?.isConnected)\")\r\n        mqttClient?.subscribe(\"ios/test\", qos: 0)\r\n        DispatchQueue.main.async {\r\n            self.mqttConfig.onMessageCallback = { msg in\r\n                print(\"asdasda \\(msg.payloadString!)\")\r\n                sleep(1)\r\n            \r\n            }\r\n            self.mqttConfig.onConnectCallback = { rtrn in\r\n                print(rtrn)\r\n            }\r\n        }\r\n        \r\n  }\r\n \r\nit does not go in onMessageCallback..."},"comment":{"url":"https://api.github.com/repos/flightonary/Moscapsule/issues/comments/389712787","html_url":"https://github.com/flightonary/Moscapsule/issues/55#issuecomment-389712787","issue_url":"https://api.github.com/repos/flightonary/Moscapsule/issues/55","id":389712787,"user":{"login":"TayyibFZ","id":39231962,"avatar_url":"https://avatars1.githubusercontent.com/u/39231962?v=4","gravatar_id":"","url":"https://api.github.com/users/TayyibFZ","html_url":"https://github.com/TayyibFZ","followers_url":"https://api.github.com/users/TayyibFZ/followers","following_url":"https://api.github.com/users/TayyibFZ/following{/other_user}","gists_url":"https://api.github.com/users/TayyibFZ/gists{/gist_id}","starred_url":"https://api.github.com/users/TayyibFZ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TayyibFZ/subscriptions","organizations_url":"https://api.github.com/users/TayyibFZ/orgs","repos_url":"https://api.github.com/users/TayyibFZ/repos","events_url":"https://api.github.com/users/TayyibFZ/events{/privacy}","received_events_url":"https://api.github.com/users/TayyibFZ/received_events","type":"User","site_admin":false},"created_at":"2018-05-17T01:09:11Z","updated_at":"2018-05-17T01:09:11Z","author_association":"NONE","body":"import UIKit\r\nimport Moscapsule\r\nimport Foundation\r\n\r\n\r\n\r\nclass dataHubView: UIViewController{\r\n    \r\n    @IBOutlet weak var humidityL: UILabel!\r\n    @IBOutlet weak var waterL: UILabel!\r\n    @IBOutlet weak var tempL: UILabel!\r\n    @IBOutlet weak var refreshM: UIButton!\r\n    @IBAction func backMain(_ sender: Any) {\r\n        self.performSegue(withIdentifier: \"backMainSegue\" , sender: self)\r\n        \r\n    }\r\n    @IBOutlet weak var backMain: UIButton!\r\n    @IBAction func refreshM(_ sender: Any) {\r\n        print(\"TEST!\")\r\n        \r\n        //mqttClient.connectTo(host: \"10.0.0.40\", port: 1883, keepAlive: 60)\r\n       \r\n        \r\n    }\r\n    \r\n    \r\n    \r\n    override func viewDidLoad() {\r\n        super.viewDidLoad()\r\n         moscapsule_init()\r\n         let mqttConfig = MQTTConfig(clientId: \"iOS\", host: \"10.0.0.40\", port: 1883, keepAlive: 60)\r\n         mqttConfig.onConnectCallback = { returnCode in\r\n         // DispatchQueue.main.async {\r\n         if returnCode == ReturnCode.success {\r\n         print(\"Connected!\")\r\n         }\r\n         else {\r\n         print(\"Error\")\r\n         }\r\n         //  }\r\n         }\r\n         mqttConfig.onMessageCallback = { mqttMessage in\r\n         // DispatchQueue.main.async {\r\n         let deku = (String(describing: mqttMessage.payloadString))\r\n         if mqttMessage.topic == \"return/temp\" {\r\n         print(\"temp\")\r\n         self.tempL.text = deku\r\n         } else if mqttMessage.topic == \"return/water\"{\r\n         print(\"water\")\r\n         self.waterL.text = deku\r\n         } else if mqttMessage.topic == \"return/humid\"{\r\n         print(\"humid\")\r\n         self.humidityL.text = deku\r\n         }\r\n         // }\r\n        }\r\n        let mqttClient = MQTT.newConnection(mqttConfig)\r\n        mqttClient.connectTo(host: \"10.0.0.40\", port: 1883, keepAlive: 9999)\r\n        mqttClient.subscribe(\"return/temp\", qos: 2)\r\n        mqttClient.subscribe(\"return/water\", qos: 2)\r\n        mqttClient.subscribe(\"return/humid\", qos: 2)\r\n        backMain.layer.cornerRadius = backMain.frame.size.height/2\r\n        backMain.layer.masksToBounds = true\r\n        backMain.setGradientBackground(colorOne: Colors.white, colorTwo: Colors.red)\r\n        refreshM.layer.cornerRadius = backMain.frame.size.height/2\r\n        refreshM.layer.masksToBounds = true\r\n        refreshM.setGradientBackground(colorOne: Colors.red, colorTwo: Colors.veryDarkGrey)\r\n        view.setGradientBackground(colorOne: Colors.black, colorTwo: Colors.green)\r\n        // Do any additional setup after loading the view, typically from a nib.\r\n      /*\r\n    */\r\n    }\r\n    override func didReceiveMemoryWarning() {\r\n        super.didReceiveMemoryWarning()\r\n        // Dispose of any resources that can be recreated.\r\n    }\r\n}  \r\n \r\nI have a very similar issue with mine everything connects and subscribes but as soon as its done it disconnects \r\n \r\n2018-05-16 18:01:52.266177-0700 Centurion[7956:3105281] [MOSQUITTO] DEBUG   Client iOS sending CONNECT\r\n2018-05-16 18:01:52.272348-0700 Centurion[7956:3105294] [MOSQUITTO] DEBUG   Client iOS received CONNACK\r\n2018-05-16 18:01:52.272702-0700 Centurion[7956:3105273] [MOSQUITTO] DEBUG   Client iOS sending CONNECT\r\n2018-05-16 18:01:52.273024-0700 Centurion[7956:3105276] [MOSQUITTO] DEBUG   Client iOS sending SUBSCRIBE (Mid: 1, Topic: return/temp, QoS: 2)\r\n2018-05-16 18:01:52.273324-0700 Centurion[7956:3105273] [MOSQUITTO] DEBUG   Client iOS sending SUBSCRIBE (Mid: 2, Topic: return/water, QoS: 2)\r\n2018-05-16 18:01:52.273524-0700 Centurion[7956:3105273] [MOSQUITTO] DEBUG   Client iOS sending SUBSCRIBE (Mid: 3, Topic: return/humid, QoS: 2)\r\n2018-05-16 18:01:52.273702-0700 Centurion[7956:3105273] [MOSQUITTO] DEBUG   Client iOS sending DISCONNECT\r\nConnected!\r\n"}}
{"actor":{"display_login":"TayyibFZ"}}