Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to Publish with CA Server Certificate #79

Open
VisRaman opened this issue Oct 24, 2018 · 0 comments
Open

Not able to Publish with CA Server Certificate #79

VisRaman opened this issue Oct 24, 2018 · 0 comments

Comments

@VisRaman
Copy link

I have a CA server certificate, using the same certificate i am able to PUBLISH the message in android using paho lib, I am not able to receive the message PUBLISHED by my iOS app using the moscapsule lib. the log shows "mosq_success", but i am not able to receive the message on the other end. The code is below -

`
func initMQTTByMoscapsule() -> Void {

    mosquitto_lib_cleanup()
    
    moscapsule_init()
    
    let mqttConfig = MQTTConfig(clientId: clientID + String(ProcessInfo().processIdentifier), host: host, port: 8883, keepAlive: 60)

    let mqttAuth = MQTTAuthOpts.init(username: userName, password: password)
    mqttConfig.mqttAuthOpts = mqttAuth
    
    let resourcePath = Bundle.main.url(forResource: "authoritycert", withExtension: "crt");
    mqttConfig.mqttServerCert = MQTTServerCert(cafile: nil, capath: resourcePath?.absoluteString)
    
    let mqttClient1 = MQTT.newConnection(mqttConfig)
    
    
    mqttClient1.connectTo(host: host, port: 8883, keepAlive: 60) { (MosqResult) in
    print("\n\n\n Return Code is \(MosqResult)")
                
    if mqttClient1.isConnected {
        print("\n\n\n Dude its is connected \n\n")
    }
                
    mqttClient1.publish(string: "test-blind-10", topic: topicToSub, qos: 0, retain: false, requestCompletion: { (resultMessage, resultcode) in
                    print("\n\n\n The PUBLISH result - \(resultMessage) \n\n")
        })
    }
    
    mqttConfig.onPublishCallback = { messageID in
        print("\n\n\n Return Code is \(messageID.description) on publish")
    }
    //mqttClient.subscribe("subscribe/topic", qos: 2)
    
    mqttConfig.onConnectCallback = { returnCode in
        print("\n\n\n Return Code is \(returnCode.description) (on Connect)")
    }
    
    `

and the resulting log is below

`[38695:1102928] [MOSQUITTO] DEBUG Client Smart***&Client38695 sending CONNECT
2018-10-24 10:27:34.845393+0530 CC[38695:1104304] [MOSQUITTO] DEBUG Client Smart***&Client38695 sending CONNECT

Return Code is mosq_success

2018-10-24 10:27:36.975967+0530 CC[38695:1102928] [MOSQUITTO] DEBUG Client Smart***&Client38695 sending PUBLISH (d0, q0, r0, m1, 'a**&-r**&-topic', ... (13 bytes))

The PUBLISH result - mosq_success

2018-10-24 10:27:38.375126+0530 CC[38695:1104304] [MOSQUITTO] DEBUG Client Smart***&Client38695 sending DISCONNECT`

still i am not receiving the message in the other end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant