Skip to content

SingleServerIRCBot exponentially increases reconnect attempts #82

@Hornwitser

Description

@Hornwitser

When the SingleServerIRCBot gets disconnected by the IRC server, it improperly handles reconnecting, causing it to double it's reconnect attempts every reconnect_interval under certain conditions.

Cause
The code handling disconnects is the following:

    def _on_disconnect(self, c, e):
        self.channels = IRCDict()
        self.connection.execute_delayed(self.reconnection_interval,
                                        self._connected_checker)

After a reconnection_interval the _connected_checker gets called.

    def _connected_checker(self):
        """[Internal]"""
        if not self.connection.is_connected():
            self.connection.execute_delayed(self.reconnection_interval,
                                            self._connected_checker)
            self.jump_server()

Which schedule another connection check and calls jump_server() to try to reconnect. If the connection attempt done by jump_server() is successful, but the client is disconnected by the IRC server (for example due to being banned), then _on_disconnect is dispatched, which schedules another connection check. And thus one connection check has turned into two.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions