So I tried to setup a simple poc, but cant get it to work. Somehow my worker does not receive any messages via the channels layer.
# asgi.py
application = ProtocolTypeRouter({
"http": django_asgi_app,
"websocket": URLRouter(websocket_urlpatterns),
"channel": ChannelNameRouter({
"node-manager": NodeManagerConsumer.as_asgi(),
})
})
# consumer.py
class NodeConsumer(WebsocketConsumer):
def connect(self):
print("attempting connection")
async_to_sync(self.channel_layer.send(
"node-manager",
{
"type": "request",
"ip": "host.docker.internal",
"port": "5123",
}
))
self.accept()
# consumer.py
class NodeManagerConsumer(SyncConsumer):
def request(self, message):
print("requested node")
This is my setup and I started the worker with python manage.py runworker node-manager but nothing happens. I dont know what Iam missing here. Redis is running and connected and when I checked the logs it does get some messages when I connect to the WebSocket Consumer.