Closed shantharsk closed 6 years ago
{_kCFStreamErrorCodeKey=1, _kCFStreamErrorDomainKey=12}
means DNS could not resolve the given hostname
You need to specify the hostaname or address 18.219.21.182
, not a URL @"ssl://18.219.21.182"
If you are connecting to AWS, you do not need MQTTSSLSecurityPolicytransport
because the CA AWS uses is well known. Use MQTTCFSocketTransport
.
Pass the client certificate as described in MQTTCFSocketTransport.h
from a .p12
file.
Please read the issues #120 and #230 to see how other users connected to AWS
Hi thanks for replay i have tried as you told I have used pl12 file in MQTTCFSocketTransport and i have mentioned only ip address please check my below code.
*NSString path = [[NSBundle mainBundle] pathForResource:@"client" ofType:@"p12"]; NSArray *myCerts = [MQTTCFSocketTransport clientCertsFromP12:path passphrase:@"123"]; if (myCerts) { self.session = [[MQTTSession alloc] init];
self.session.delegate = self;
self.session.clientId = [[NSBundle mainBundle] bundleIdentifier];
self.session.certificates = myCerts;
[self.session connectToHost:@"18.219.21.182" port:7962 usingSSL:YES];
}**
But im still facing issue like connection refused.
2018-04-11 15:21:21.801671+0530 MQTTOBJSample[6318:2333962] MQTTSessionLegacy connectToHost:18.219.21.182 port:7962 usingSSL:1 connectHandler:0x0 2018-04-11 15:21:21.803064+0530 MQTTOBJSample[6318:2333962] [MQTTSession] connectWithConnectHandler:0x0 2018-04-11 15:21:21.803181+0530 MQTTOBJSample[6318:2333962] [MQTTSession] connecting 2018-04-11 15:21:21.805133+0530 MQTTOBJSample[6318:2333962] [MQTTCFSocketTransport] open 2018-04-11 15:21:21.808399+0530 MQTTOBJSample[6318:2333962] [MQTTCFSocketEncoder] setState 0/0 2018-04-11 15:21:22.073668+0530 MQTTOBJSample[6318:2334030] [] nw_connection_get_connected_socket 1 Connection has no connected handler 2018-04-11 15:21:22.073732+0530 MQTTOBJSample[6318:2334030] TCP Conn 0x100ea61f0 Failed : error 0:61 [61] 2018-04-11 15:21:22.073941+0530 MQTTOBJSample[6318:2333962] [MQTTCFSocketEncoder] NSStreamEventErrorOccurred 2018-04-11 15:21:22.073990+0530 MQTTOBJSample[6318:2333962] [MQTTCFSocketEncoder] setState 0/2 2018-04-11 15:21:22.074213+0530 MQTTOBJSample[6318:2333962] [MQTTSession] mqttTransport didFailWithError Error Domain=NSPOSIXErrorDomain Code=61 "Connection refused" UserInfo={_kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1} 2018-04-11 15:21:22.081986+0530 MQTTOBJSample[6318:2333962] -----< called 3 The operation couldn’t be completed. Connection refused 2018-04-11 15:21:22.082454+0530 MQTTOBJSample[6318:2333962] [MQTTSession] closeInternal 2018-04-11 15:21:22.082546+0530 MQTTOBJSample[6318:2333962] [MQTTCFSocketTransport] close 2018-04-11 15:21:22.082962+0530 MQTTOBJSample[6318:2333962] -----< called 2 (null)
Any idea about this issue.
didFailWithError Error Domain=NSPOSIXErrorDomain Code=61 "Connection refused"
Check the host address and the port with AWS. This is not an MQTT issue
@ckrey
I am trying to connect to aws IoT using your library but I am unable to establish a connection. I am using URL as
let url = protocol + '://' + host + uri + '?' + canonicalQuerystring
let wsTransport = MQTTWebsocketTransport()
wsTransport.host = url
wsTransport.port = 0
newSession.transport = wsTransport
newSession.connect()
I have removed using TLS property in the transport layer and modified the file. I am unable to establish a connection. Can you please help?
@mendirattanishant check https://github.com/novastone-media/MQTT-Client-Framework/issues/433, it could be similar issue.
I will close this issue due to no activity. Feel free to reopen if you still have the same problem.
Hi, could you explain to me please why when I connect to the host I get this: "mqttTransport didFailWithError Error Domain=kCFErrorDomainCFNetwork Code=1 "(null)" UserInfo={_kCFStreamErrorCodeKey=1, _kCFStreamErrorDomainKey=12}"
This code which im using
*NSString ca1 = [[NSBundle bundleForClass:[MQTTSession class]] pathForResource:@"client" ofType:@"crt"]; NSString ca2 = [[NSBundle bundleForClass:[MQTTSession class]] pathForResource:@"ca" ofType:@"crt"]; NSString ca3 = [[NSBundle bundleForClass:[MQTTSession class]] pathForResource:@"client" ofType:@"key"];
// securityPolicy.pinnedCertificates = @[[NSData dataWithContentsOfFile:ca2], [NSData dataWithContentsOfFile:client]]; securityPolicy.allowInvalidCertificates = YES; securityPolicy.validatesDomainName = NO; securityPolicy.validatesCertificateChain = NO; // MQTTSSLSecurityPolicyTransport *secureTransport = [[MQTTSSLSecurityPolicyTransport alloc] init]; secureTransport.host = @"ssl://18.219.21.182"; secureTransport.port = 7926; secureTransport.tls = YES; secureTransport.securityPolicy = securityPolicy;
[session connectAndWaitTimeout:30];**
When trying to run this im getting this error
2018-04-10 18:17:45.739471+0530 MQTTOBJSample[499:212507] [MQTTSession] connecting 2018-04-10 18:17:45.740364+0530 MQTTOBJSample[499:212507] [MQTTSSLSecurityPolicyTransport] open 2018-04-10 18:17:45.742029+0530 MQTTOBJSample[499:212507] [MQTTCFSocketEncoder] setState 0/0 2018-04-10 18:17:45.742649+0530 MQTTOBJSample[499:212507] [MQTTSessionSynchron] waiting for connect 2018-04-10 18:17:45.743374+0530 MQTTOBJSample[499:212507] [MQTTCFSocketEncoder] NSStreamEventErrorOccurred 2018-04-10 18:17:45.743401+0530 MQTTOBJSample[499:212507] [MQTTCFSocketEncoder] setState 0/2 2018-04-10 18:17:45.743524+0530 MQTTOBJSample[499:212507] [MQTTSession] mqttTransport didFailWithError Error Domain=kCFErrorDomainCFNetwork Code=1 "(null)" UserInfo={_kCFStreamErrorCodeKey=1, _kCFStreamErrorDomainKey=12} 2018-04-10 18:17:45.743870+0530 MQTTOBJSample[499:212507] [MQTTSession] closeInternal 2018-04-10 18:17:45.743908+0530 MQTTOBJSample[499:212507] [MQTTCFSocketTransport] close 2018-04-10 18:17:45.843827+0530 MQTTOBJSample[499:212507] [MQTTSessionSynchron] end connect 2018-04-10 18:17:45.844740+0530 MQTTOBJSample[499:212507] [MQTTCFSocketTransport] close
Can you please help me out with this issue i have stuck for long.
Thanks.