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

Unable to connect #98

Closed
yasirtahir opened this issue Oct 4, 2016 · 6 comments
Closed

Unable to connect #98

yasirtahir opened this issue Oct 4, 2016 · 6 comments

Comments

@yasirtahir
Copy link

I have a MQTT over WebSocket host with NodeRed. I am using this library in order to connect but I am getting the following error:

Error Domain=GCDAsyncSocketErrorDomain Code=7 "Socket closed by remote peer" UserInfo={NSLocalizedDescription=Socket closed by remote peer}

Code:
let clientIdPid = "CocoaMQTT-" + String(NSProcessInfo().processIdentifier)
let mqtt = CocoaMQTT(clientId: clientIdPid, host: "95.177.135.232", port: 9001)
mqtt.cleanSess = true
mqtt.keepAlive = 60
mqtt.delegate = self
mqtt.connect()

@CrazyWisdom
Copy link
Member

Is 9001 the WebSocket port? CocoaMQTT now only supports tcp connections.

@Decrypto
Copy link

FWIW, since updating to Swift 3 I've been getting the same:

Did disconnect with error: Optional(Error Domain=GCDAsyncSocketErrorDomain Code=7 "Socket closed by remote peer" UserInfo={NSLocalizedDescription=Socket closed by remote peer})

This is against AdafruitIO, io.adafruit.com:1883
Sometimes it will stay connected for a few pings. Sometimes it resets almost immediately. KeepAlive = 90.

@axpence
Copy link

axpence commented May 18, 2017

I'm having this issue as well. Any ideas?

    func mqttSetting() {
//        let clientID = "CocoaMQTT-" + String(ProcessInfo().processIdentifier)
        let clientID = "myclientid_101"
        mqtt = CocoaMQTT(clientID: clientID, host: "159.203.240.XX", port: 8000)
//        mqtt!.username = ""
//        mqtt!.password = ""
//        mqtt!.willMessage = CocoaMQTTWill(topic: "/will", message: "dieout")
        mqtt!.keepAlive = 90
        mqtt!.cleanSession = true
//        mqtt?.secureMQTT = true
        mqtt!.delegate = self
    }

I have tried about every permutation of the commented out settings... still no luck

@alexyu1989
Copy link
Contributor

@axpence I have tried your host. The host's port 8000 fail, but port 1883 succeed. Please check your host port 8000. Thanks.

@axpence
Copy link

axpence commented May 18, 2017

@alexyu1989 nice name :). You are correct, I had the incorrect port. Thanks for your help! Sorry for the n00b question.

@alexyu1989
Copy link
Contributor

@axpence You are welcome. Have fun with the framework :)

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

5 participants