Skip to content

Reconnect Fail #114

Open
Open
@wanZzz6

Description

My client disconnected from broker, but an error occurred while it try to reconnect . The client can't reconnect again but the event_loop still run. Maybe there should be an on_error() callback function set on the client.

I check the source code in `gmqtt.mqtt.handler'

    def _handle_disconnect_packet(self, cmd, packet):
        # reset server topics on disconnect
        self._clear_topics_aliases()

        future = asyncio.ensure_future(self.reconnect(delay=True))
        future.add_done_callback(self._handle_exception_in_future)
        self.on_disconnect(self, packet)

    def _handle_exception_in_future(self, future):
        if future.exception():
            logger.warning('[EXC OCCURED] in reconnect future %s', future.exception())
            return

If the reconnect future run fail, and the callback _handle_exception_in_future Just print a log info ......, Why not do a reconnection after some seconds?

About the on_disconnect() callback (In ‘README.md’)

def on_disconnect(client, packet, exc=None):
    print('Disconnected') 

I define the exe param, but the source code in gmqtt.mqtt.handler

    def _handle_disconnect_packet(self, cmd, packet):
        # reset server topics on disconnect
        self._clear_topics_aliases()

        future = asyncio.ensure_future(self.reconnect(delay=True))
        future.add_done_callback(self._handle_exception_in_future)
        self.on_disconnect(self, packet)

In Fact , self.on_disconnect(self, packet) did not pass an exe param, I want get more exception infomation in the callback() , andI really need it !!!

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