Error Domain=MQTT Code=-8 "Server has closed connection without connack." UserInfo={NSLocalizedDescription=Server has closed connection without connack.}
vidhya11v opened this issue · 0 comments
vidhya11v commented
This is the code which I tried
let sessionManager = MQTTSessionManager()
sessionManager.delegate = self
let userName = ""
let password = ""
let certificate = Bundle.main.path(forResource: "ca", ofType: "crt")
let securityPolicy = MQTTSSLSecurityPolicy.init(pinningMode: .certificate)
securityPolicy?.allowInvalidCertificates = true
securityPolicy?.pinnedCertificates = [NSData.init(contentsOfFile: certificate!)!]
securityPolicy?.validatesCertificateChain = false
securityPolicy?.validatesDomainName = false
sessionManager.connect(to: MQTT_HOST, port: Int(MQTT_PORT), tls: true, keepalive: 60, clean: true, auth: false, user: nil, pass: nil, will: false, willTopic: nil, willMsg: nil, willQos: .atMostOnce, willRetainFlag: false, withClientId: "client-1", securityPolicy: securityPolicy, certificates: [NSData.init(contentsOfFile: certificate!)!], protocolLevel: .version311, connectHandler:nil
)