Ok, but that doesnt'solve the problem with handling the events in the right
process.
Anyway, I think I figured it out. It seems there is nothing magical to a
'protocol handler' after all, so I can just create a thread with its event
loop and run the MQTT listener in there. No other processes r
for example:
from asgiref.sync import async_to_sync as a2s
from channels.layers import get_channel_layer
from channels_mqtt import settings
event = {"type": settings.MQTT_PUBLISH, "text": {"topic": topic, "payload":
payload, "qos": qos, "retain": retain}}
a2s(channel_layer.send)(channel, event)
you could send message to channel "mqtt" that defined in routing.py via
django channels usage
Andrea Conti於 2019年5月2日星期四 UTC+8下午11時17分02秒寫道:
>
>
> First of all, thanks for responding.
>
> While the example does route the incoming MQTT messages to a consumer, the
> consumer is still in the same
First of all, thanks for responding.
While the example does route the incoming MQTT messages to a consumer, the
consumer is still in the same process as the MQTT client, i.e. the one
started with "runmqttworker" management command.
What I am trying to do is tohandle those events within another
have a try of https://github.com/ruralscenery/channels_mqtt
Andrea Conti於 2019年5月2日星期四 UTC+8下午7時40分20秒寫道:
>
> Hello,
>
> I am trying to use Channels 2 to implement an http/websocket application
> which also handles asynchronous requests from a second source (right now
> it's messages from an
Hello,
I am trying to use Channels 2 to implement an http/websocket application
which also handles asynchronous requests from a second source (right now
it's messages from an MQTT subscription, but I think the problem is largely
independent from the specific protocol). This doesn't seem to be
6 matches
Mail list logo