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

Reconnection issue #15

Open
NancyZY opened this issue Nov 16, 2016 · 5 comments
Open

Reconnection issue #15

NancyZY opened this issue Nov 16, 2016 · 5 comments

Comments

@NancyZY
Copy link

NancyZY commented Nov 16, 2016

How to deal with the reconnection,? I try to in mqttDidDisconnect method call the connection method, Is it right action?

@bhargavg
Copy link
Collaborator

Yes, what is the actual issue that you are facing?

@NancyZY
Copy link
Author

NancyZY commented Nov 17, 2016

when I use the library to app, it connect successfully, but sometimes it may disconnected, then I tried to in mqttDidDisconnect method call the connection method, like below code:func mqttDidDisconnect(session: MQTTSession) { connect(session) print("Session Disconnected.") }, the result shows 6596 Connection has no connected handler? what does it mean?

@bhargavg
Copy link
Collaborator

From the error message, I guess the session delegate is getting deallocated.

Also, what is connect(session) method doing? Why does it need an already closed session to reconnect again?

@NancyZY
Copy link
Author

NancyZY commented Nov 18, 2016

Because I want the connection always keep alive. I use it to receive the other client published message. And if it disconnect, it should try to connect. The connect(session) method is like that :

func connect(_ mqttSession : MQTTSession) -> Void {
        mqttSession.connect {
            if !$0 {
                print("Error Occurred During connection \($1)")
                return
            }
            mqttSession.subscribe(to: "topic", delivering: .atLeastOnce) { (succeeded, error) -> Void in
                if succeeded {
                    print("Subscribed!")
                }
            }
        }
    }```
,  Is everything right here ?

@mahesh07513
Copy link

mahesh07513 commented Feb 9, 2017

i am using same SwiftMQTT only , canu tell me how subscribe with Messege, i am getting only subscribe name

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

3 participants