-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
… conditions on detached sessions, eliminated set_exception on client disconnect tasks, a few debug log message isEnabledFor wrappers.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -707,21 +707,25 @@ def _broadcast_loop(self): | |
if 'qos' in broadcast: | ||
qos = broadcast['qos'] | ||
if target_session.transitions.state == 'connected': | ||
self.logger.debug("broadcasting application message from %s on topic '%s' to %s" % | ||
(format_client_message(session=broadcast['session']), | ||
broadcast['topic'], format_client_message(session=target_session))) | ||
if self.logger.isEnabledFor(logging.DEBUG): | ||
self.logger.debug("broadcasting application message from %s on topic '%s' to %s" % | ||
(format_client_message(session=broadcast['session']), | ||
broadcast['topic'], format_client_message(session=target_session))) | ||
handler = self._get_handler(target_session) | ||
task = asyncio.ensure_future( | ||
handler.mqtt_publish(broadcast['topic'], broadcast['data'], qos, retain=False), | ||
loop=self._loop) | ||
running_tasks.append(task) | ||
else: | ||
self.logger.debug("retaining application message from %s on topic '%s' to client '%s'" % | ||
(format_client_message(session=broadcast['session']), | ||
broadcast['topic'], format_client_message(session=target_session))) | ||
elif qos is not None and qos > 0: | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
shipmints
Author
Contributor
|
||
if self.logger.isEnabledFor(logging.DEBUG): | ||
self.logger.debug("retaining application message from %s on topic '%s' to client '%s'" % | ||
(format_client_message(session=broadcast['session']), | ||
broadcast['topic'], format_client_message(session=target_session))) | ||
retained_message = RetainedApplicationMessage( | ||
broadcast['session'], broadcast['topic'], broadcast['data'], qos) | ||
yield from target_session.retained_messages.put(retained_message) | ||
if self.logger.isEnabledFor(logging.DEBUG): | ||
This comment has been minimized.
Sorry, something went wrong.
HerrMuellerluedenscheid
|
||
self.logger.debug(f'target_session.retained_messages={target_session.retained_messages.qsize()}') | ||
except CancelledError: | ||
# Wait until current broadcasting tasks end | ||
if running_tasks: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -456,7 +456,7 @@ def cancel_tasks(): | |
while self.client_tasks: | ||
task = self.client_tasks.popleft() | ||
if not task.done(): | ||
task.set_exception(ClientException("Connection lost")) | ||
task.cancel() | ||
This comment has been minimized.
Sorry, something went wrong.
HerrMuellerluedenscheid
|
||
|
||
self.logger.debug("Watch broker disconnection") | ||
# Wait for disconnection from broker (like connection lost) | ||
|
@shipmints I think this is wrong. It means that only messages with
qos>0
can be retained. As far as I understand theretained
flag it does not have an effect onqos
and vice versa. That's how I understand this resource: http://www.steves-internet-guide.com/mqtt-retained-messages-example/Pay special attention to 'common questions and answers' section.
Also the test
test_broker.BrokerTest.test_client_publish_retain_subscribe
was designed withretained=1
andqos=0
to be published. Thus, either fix the code or fix the test.