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

Check/recheck connection to XMPP server #13

Open
debbabi opened this issue Apr 20, 2015 · 2 comments
Open

Check/recheck connection to XMPP server #13

debbabi opened this issue Apr 20, 2015 · 2 comments

Comments

@debbabi
Copy link
Member

debbabi commented Apr 20, 2015

Line: 162
https://github.com/isandlaTech/cohorte-herald/blob/master/python/herald/transports/xmpp/transport.py#L162

Fix by something like that one:

        # Connect to the server
        from time import sleep
        tries_delay = 5
        max_tries = 3
        tries = range(max_tries)
        connected = False
        for tries_remaining in tries:
            if self._bot.connect(self._host, self._port):
                connected = True
                break
            else:
                sleep(tries_delay)
        if connected == False:
        # if not self._bot.connect(self._host, self._port):
            _logger.error("Can't connect to the XMPP server at %s port %s",
                          self._host, self._port)
@tcalmant
Copy link
Member

Another solution could be to use a third argument in self._bot.connect(), which is reattempt (boolean).
In this case, it would also be necessary to add a reconnect_max_attempts member to the self._bot object to control the number of attempts.

self._bot.reconnect_max_attempts = 3
if not self._bot.connect(self._host, self._port, True):
   _logger.error("Can't connect to the XMPP server at %s port %s",
                      self._host, self._port)

@tcalmant
Copy link
Member

Looking at the Event Index of SleekXMPP, the following ones could give hints about connection failures:

  • disconnected, regarding if the session ended before receiving this event
  • connection_failed, from xmlstream.py@782

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants