You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Calling client.subscribe([]) should fail/return immediately, but it gets passed on to the paho client, which happily subscribes to no topics. The client.subscribe function then sets up a callback to wait for paho to fire an on_subscribe callback, but it never does, because there were no topics subscribed to.
asyncdefsubscribe(self, *args, timeout=10, **kwargs):
result, mid=self._client.subscribe(*args, **kwargs)
# Early out on errorifresult!=mqtt.MQTT_ERR_SUCCESS:
raiseMqttCodeError(result, 'Could not subscribe to topic')
# Create future for when the on_subscribe callback is calledcb_result=asyncio.Future()
withself._pending_call(mid, cb_result):
# Wait for cb_resultreturnawaitself._wait_for(cb_result, timeout=timeout)
The text was updated successfully, but these errors were encountered:
As a side note, does this callback mechanism support multiple subscriptions? Does paho call back with once per subscribed topic, or once per invocation of self._client.subscribe()?
Nice find. I never tested this case. Reminds me that we also need test cases. :))
As a side note, does this callback mechanism support multiple subscriptions? Does paho call back with once per subscribed topic, or once per invocation of self._client.subscribe()?
I'm not sure that I completely follow. :)
When we call self._client.subscribe(), paho sends a SUBSCRIBE packet.
When paho receives a SUBACK packet from the server, it calls the on_subscribe callback.
There is also this interesting sentence from the MQTTv5 spec:
When the Server receives a SUBSCRIBE packet from a Client, the Server MUST respond with a SUBACK packet.
So if everything goes as planned (e.g., no network errors), we will receive exactly one on_subscribe call for every self._client.subscribe call that we make.
Calling
client.subscribe([])
should fail/return immediately, but it gets passed on to the paho client, which happily subscribes to no topics. Theclient.subscribe
function then sets up a callback to wait for paho to fire anon_subscribe
callback, but it never does, because there were no topics subscribed to.Recreate with:
The
client.subscribe
function for reference:The text was updated successfully, but these errors were encountered: