In my consumer, on connect, I add the user to their own private channel.
As the user is anonymous when connecting, I use the channel_name as an identifier and create a private channel with it.
async def connect(self):
# add the user to their private group. Because
# we add the user before they identify themselves
# via the gateway we cannot get the user's id.
# Hence we use the channel name as a substitute
# for the private group's unique identifier.
await self.channel_layer.group_add(
group=self.channel_name,
channel=self.channel_name
)
await self.accept()
# indicate the user that they have
# connected to the gateway successfully.
await self.hello()
something like this.
However, I am getting ASCII string errors.
traceback:
File "C:\Users\iyapp\PycharmProjects\rebox\plixn_django\apps\gateway\consumers.py", line 79, in connect
await self.channel_layer.group_add(
File "C:\Users\iyapp\Envs\rebox_django\lib\site-packages\channels_redis\core.py", line 618, in group_add
assert self.valid_group_name(group), "Group name not valid"
File "C:\Users\iyapp\Envs\rebox_django\lib\site-packages\channels\layers.py", line 165, in valid_group_name
raise TypeError(
TypeError: Group name must be a valid unicode string containing only ASCII alphanumerics, hyphens, or periods.
If I cannot use the channel_name as a unique identifier, are there any alternatives?
If I am not wrong, this was the recommended way of adding users to their own channels earlier.
In my consumer, on connect, I add the user to their own private channel.
As the user is anonymous when connecting, I use the channel_name as an identifier and create a private channel with it.
something like this.
However, I am getting ASCII string errors.
traceback:
If I cannot use the channel_name as a unique identifier, are there any alternatives?
If I am not wrong, this was the recommended way of adding users to their own channels earlier.