-
Notifications
You must be signed in to change notification settings - Fork 53
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
Reconnect Fail #114
Comments
My solution: class MyClient(MQTTClient):
async def reconnect(self, delay=False):
if not self._allow_reconnect():
return
# stopping auto-reconnects during reconnect procedure is important, better do not touch :(
self._temporatily_stop_reconnect()
############# My Solution #################
try:
await self._disconnect()
except Exception as e:
logger.error('Disconnected Error!')
##########################################
if delay:
await asyncio.sleep(self._config['reconnect_delay'])
try:
self._connection = await self._create_connection(self._host, self._port, ssl=self._ssl,
clean_session=False, keepalive=self._keepalive)
except OSError as exc:
self.failed_connections += 1
logger.warning("[CAN'T RECONNECT] %s", self.failed_connections)
asyncio.ensure_future(self.reconnect(delay=True))
return
await self._connection.auth(self._client_id, self._username, self._password,
will_message=self._will_message, **self._connect_properties) |
I've created a PR (#119) with some instructions on how to reproduce it and a test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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'
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’)I define the
exe
param, but the source code ingmqtt.mqtt.handler
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 !!!The text was updated successfully, but these errors were encountered: