I don't really understand what is causing the issue.
I have my configuration setup like so:
# Channels Config
CHANNEL_LAYERS = {
"default": {
"BACKEND": "channels_rabbitmq.core.RabbitmqChannelLayer",
"CONFIG": {
"host": "HOSTURLREMOVED",
},
},
}
And I'm trying to call this:
# Broadcast trade to all connected clients via channel layer (websockets)
try:
from channels.layers import get_channel_layer
channel_layer = get_channel_layer()
await channel_layer.group_send(
str(bot.id), # The bot's id is used as the group name
{
'type': 'bot_trade', # This matches the name of a method in the consumer
'message': {MESSAGEREMOVED},
}
)
except Exception as e:
# Failed to broadcast trade
print(e)
this is being called from a django view which executes a trade function, that trade function executes another function where this call is located.
an error always pops up in the terminal "The caller tried using channels_rabbitmq on a different event loop than the one it was initialized with."
Usually this error happens when trying to use django channels logic inside a celery function but I'm not.
Do you know what could be going wrong?
I don't really understand what is causing the issue.
I have my configuration setup like so:
And I'm trying to call this:
this is being called from a django view which executes a trade function, that trade function executes another function where this call is located.
an error always pops up in the terminal "The caller tried using channels_rabbitmq on a different event loop than the one it was initialized with."
Usually this error happens when trying to use django channels logic inside a celery function but I'm not.
Do you know what could be going wrong?