Closed yusufonderd closed 6 years ago
@yusufonderd try this:
let transport: MQTTWebsocketTransport = MQTTWebsocketTransport()
transport.host = "a2xxxxxxxx.iot.us-east-1.amazonaws.com"
transport.path = "/mqtt?..."
transport.port = 443
transport.tls = true
session.transport = transport
session.userName = "your-username"
session.password = "your-password"
session.protocolLevel = .version311
session.clientId = String(ProcessInfo().processIdentifier)
session.connect()
MQTTCFSocketTransport object has not 'path' properties.
@yusufonderd updated the answer with the right transport
@NathanMrtns Now I'm getting two different error when change tls value :
When transport.tls = true
: Error Domain=SRWebSocketErrorDomain Code=2132 "received bad response code from server 403" UserInfo={NSLocalizedDescription=received bad response code from server 403, HTTPResponseStatusCode=403}
When transport.tls = false
: Error Domain=MQTT Code=-8 "Server has closed connection without connack." UserInfo={NSLocalizedDescription=Server has closed connection without connack.}
@yusufonderd do you need a certificate to connect?
No I'm using generated URL. This url already authorized. Not need a certificate.
@yusufonderd I'm not sure, but I believe you have to change your AWS host config.
Check this issues and see if it helps #120 and #433
Hi @NathanMrtns I see this log in xcode when connect socket :
MQTTSessionLegacy connectToHost:xxxxxxx.iot.us-east-1.amazonaws.com port:443 usingSSL:1 connectHandler:0x0 [MQTTSession] connectWithConnectHandler:0x0 [MQTTSession] connecting [MQTTCFSocketTransport] open [MQTTCFSocketEncoder] setState 0/0 [MQTTCFSocketDecoder] NSStreamEventOpenCompleted [MQTTCFSocketEncoder] NSStreamEventOpenCompleted [MQTTCFSocketEncoder] NSStreamEventHasSpaceAvailable [MQTTCFSocketEncoder] setState 0/1 [MQTTSession] mqttTransportDidOpen [MQTTSession] sending CONNECT [MQTTMessage] wireFormat(39)=<10250006 4d514973 64700302 003c0017 496e646f 6f725472 696f5365 7344656e 656d6532 393139>... [MQTTSession] mqttTransport send [MQTTCFSocketEncoder] buffer to write (39)=<10250006 4d514973 64700302 003c0017 496e646f 6f725472 696f5365 7344656e 656d6532 393139>... [MQTTCFSocketEncoder] NSStreamEventHasSpaceAvailable
Do you have any idea ?
Hi @yusufonderd. As @NathanMrtns pointed, please check https://github.com/novastone-media/MQTT-Client-Framework/issues/433 to work with signed url. You will need to subclass MQTTWebsocketTransport
Tracked in #433
I'm trying to connect aws signed url.
I give an exception :
cError:Optional(Error Domain=kCFErrorDomainCFNetwork Code=1 "(null)" UserInfo={_kCFStreamErrorCodeKey=1, _kCFStreamErrorDomainKey=12})