-
Notifications
You must be signed in to change notification settings - Fork 93
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
Autopaho set DefaultPinger on ClientConfig can't reconnect to server after disconnection #227
Comments
I thought something like func (p *DefaultPinger) Run(conn net.Conn, keepAlive uint16) error {
...
err := <-p.errChan
p.reset()
return err
} But stopped Pinger with error causes client stops, if err := c.config.PingHandler.Run(c.config.Conn, keepalive); err != nil {
go c.error(fmt.Errorf("ping handler error: %w", err))
} And it causes Pinger stops again, so some values become dirty again func (c *Client) close() {
...
c.config.PingHandler.Stop()
...
} |
Thanks for reporting this so quickly; great bug report, but I'm not sure that I agree with the above because I believe the error will prevent the autopaho from reconnecting (ping handler returning error leads to call to |
Opened a PR with |
Thanks for the PR. I'm going to have a quick look at an alternative approach; being able to reuse the pinger and having a |
Clarifying this; the issue will prevent I started looking at using Context to handle this, and it was one of those changes that just seemed to expand. PR (#229) addresses this issue but also makes a range of other fairly major changes (I believe it makes it easier to follow the termination process). @vishnureddy17 apologies; my PR significantly changes the implementation of Pinger you recently submitted. I'm not committed to making this change but I do feel it's considerably simpler (assuming I have not missed anything). Would really appreciate your thoughts. The PR also makes it clear that |
@MattBrittan Just reviewed your PR, and like that approach. |
Describe the bug
Autopaho set DefaultPinger on ClientConfig can't reconnect to the server after disconnection
Found this bug while using DefalutPinger with logger to test Pinger with autopaho (I guess this is only usecase for now)
To reproduce
Debug output
Expected behaviour
autopaho should be able to reconnect to the server even previous client was closed.
Software used:
Additional context
It happens because the values of Pinger in paho.ClientConfig is changed and autopaho uses this changed values to reconnect to the server
timer is set while Run()
so the timer of the Pinger in paho.ClientConfig is not nil after that, and it causes
return fmt.Errorf("Run() already called")
while trying reconnectionIt's not only problem of timer, but done(+ other channels I guess?) and stopOnce should also be initialized in order to work correctly
This is not a critical bug because users don't need logger for production, but it would be good to fix I guess.
The text was updated successfully, but these errors were encountered: