-
I’m not seeing the debugging information that you posted at group_send fired but consumer is not receiving - #8 by B4sic101
I can’t see where you’re making an attempt to send a message. -
I am not seeing any point in time in this log where you have two users logged on concurrently.
Those tests were seperate + Im not sure how its possible that they are not logged on concurrently I’m using each in isolated tabs and they function fine. Heres a test with group_send fired:
***apps.py loaded***
***signals.py loaded***
***apps.py loaded***
***signals.py loaded***
Watching for file changes with StatReloader
Performing system checks...
***forms.py loaded***
System check identified no issues (0 silenced).
January 29, 2025 - 23:59:02
Django version 5.1.4, using settings 'app_dependencies.settings'
Starting ASGI/Daphne version 4.1.2 development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
HTTP GET /dashboard/ 200 [0.02, 127.0.0.1:49284]
HTTP GET /static/dashboard/main/main.css 200 [0.01, 127.0.0.1:49284]
HTTP GET /static/dashboard/main/main.js 200 [0.00, 127.0.0.1:49290]
WebSocket HANDSHAKING /ws/notifyFR/ [127.0.0.1:49302]
HTTP GET /static/dummyUser.png 200 [0.00, 127.0.0.1:49290]
---- Jerry Kole with a userID of 3f1e0afe-64ac-4ce4-b5e3-dd5cb4b4555e is in the group noti_3f1e0afe-64ac-4ce4-b5e3-dd5cb4b4555e.
WebSocket CONNECT /ws/notifyFR/ [127.0.0.1:49302]
HTTP GET /uploads/profiles/user_3f1e0afe-64ac-4ce4-b5e3-dd5cb4b4555e.jpeg 200 [0.01, 127.0.0.1:49284]
HTTP GET /dashboard/ 200 [0.02, 127.0.0.1:49316]
HTTP GET /static/dashboard/main/main.css 200 [0.00, 127.0.0.1:49316]
HTTP GET /static/dashboard/main/main.js 200 [0.00, 127.0.0.1:49322]
HTTP GET /static/dummyUser.png 200 [0.00, 127.0.0.1:49316]
HTTP GET /uploads/profiles/user_16bb0918-aa22-44e3-8864-8b639a915190.jpeg 200 [0.01, 127.0.0.1:49322]
WebSocket HANDSHAKING /ws/notifyFR/ [127.0.0.1:49326]
---- Frank with a userID of 16bb0918-aa22-44e3-8864-8b639a915190 is in the group noti_16bb0918-aa22-44e3-8864-8b639a915190.
WebSocket CONNECT /ws/notifyFR/ [127.0.0.1:49326]
HTTP GET /api/get-userid?username=Frank 200 [0.01, 127.0.0.1:49332]
Hello {'receiver': '16bb0918-aa22-44e3-8864-8b639a915190'}
fr made
HTTP POST /api/add-contact 201 [0.11, 127.0.0.1:49332]
{"requestID":"73edd407-3082-4f43-ae30-c2caa7c56c09"}
------------- TRUTH TABLE -------------
Target Group: noti_16bb0918-aa22-44e3-8864-8b639a915190
Receiver: Frank
Sender: Jerry Kole
Own Group Name: noti_3f1e0afe-64ac-4ce4-b5e3-dd5cb4b4555e
---------------- OUTPUTS ---------------
Sending to...noti_16bb0918-aa22-44e3-8864-8b639a915190
Succesfully sent message to group
And there’s nothing at all after the “Succesfully sent message to group” line?
I’m not seeing anything wrong with the code or the output posted so far - there’s something happening that isn’t visible yet.
The print function is by default, buffered. It’s possible that the print statements in frNotifier
aren’t being seeing because of an error preventing the buffered output from being emitted.
There are two ways you can force the output to be unbuffered.
The first, and the easiest to do without modifying your code, is to add the -u
parameter to your python
command to run your server. e.g. python -u manage.py runserver
The other would be to add the flush=True
parameter in your print calls. e.g. print("Some text", flush=True)
. You would need to do this in every print function.
Doing this and repeating the test may reveal additional information about any errors occurring.
Side note 1: You’ve got some redundant and unnecessary code that you may want to consider cleaning up.
First, you have:
You’re issuing two queries for the same data. These lines can be replaced with:
friend_request = friendRequest.objects.get(requestID=reqID)
receiver_user_id = friend_request.receiver
sender_user_id = friend_request.sender
sender = User.objects.get(userID=sender_user_id).username
targetGrp = f'noti_{receiver_user_id}'
receiver = User.objects.get(userID=receiver_user_id).username
Side note 2: I would encourage you to adopt the standard Python / Django naming conventions for entity names. That would mean capitalized class names (e.g. FriendRequest
instead of friendRequest
for model names) and underscored variable and function names (e.g. fr_notify
instead of frNotify
)
While neither of these suggestions are required changes and are not directly relevent to your current issue, the first has performance implications and the second would help other people who need to read and understand your code.
Thanks for the tips. I tried what you said but there was no difference in output, I also tried combining verbose output with these changes but I cannot see anything of interest; due to limited characters I cant send the previous section of the output but it was just more DEBUG file reloads:
...
DEBUG 2025-01-30 07:13:16,182 autoreload File /home/default/NEA-Project/CrypTalk/venv/lib/python3.12/site-packages/django/contrib/contenttypes/migrations/0001_initial.py first seen with mtime 1735489103.0379376
DEBUG 2025-01-30 07:13:16,182 autoreload File /home/default/NEA-Project/CrypTalk/venv/lib/python3.12/site-packages/channels/middleware.py first seen with mtime 1737494100.9078395
DEBUG 2025-01-30 07:13:16,182 autoreload File /home/default/NEA-Project/CrypTalk/venv/lib/python3.12/site-packages/django/db/migrations/graph.py first seen with mtime 1735489103.246418
DEBUG 2025-01-30 07:13:20,342 utils (0.000)
SELECT VERSION(),
@@sql_mode,
@@default_storage_engine,
@@sql_auto_is_null,
@@lower_case_table_names,
CONVERT_TZ('2001-01-01 01:00:00', 'UTC', 'UTC') IS NOT NULL
; args=None; alias=default
DEBUG 2025-01-30 07:13:20,342 utils (0.000) SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; args=None; alias=default
DEBUG 2025-01-30 07:13:20,342 utils (0.000) SELECT `django_session`.`session_key`, `django_session`.`session_data`, `django_session`.`expire_date` FROM `django_session` WHERE (`django_session`.`expire_date` > '2025-01-30 07:13:20.339470' AND `django_session`.`session_key` = 'ct5m448zca7p1vczx1yeawezj5b48zc7') LIMIT 21; args=('2025-01-30 07:13:20.339470', 'ct5m448zca7p1vczx1yeawezj5b48zc7'); alias=default
DEBUG 2025-01-30 07:13:20,343 utils (0.000) SELECT `src_user`.`last_login`, `src_user`.`userID`, `src_user`.`username`, `src_user`.`email`, `src_user`.`password`, `src_user`.`profileImage`, `src_user`.`created_at`, `src_user`.`notificationSFX`, `src_user`.`is_active`, `src_user`.`is_admin` FROM `src_user` WHERE `src_user`.`userID` = '3f1e0afe64ac4ce4b5e3dd5cb4b4555e' LIMIT 21; args=('3f1e0afe64ac4ce4b5e3dd5cb4b4555e',); alias=default
DEBUG 2025-01-30 07:13:20,343 utils (0.000) SELECT `api_friendrequest`.`requestID`, `api_friendrequest`.`sender`, `api_friendrequest`.`receiver` FROM `api_friendrequest` WHERE `api_friendrequest`.`receiver` = '3f1e0afe64ac4ce4b5e3dd5cb4b4555e'; args=('3f1e0afe64ac4ce4b5e3dd5cb4b4555e',); alias=default
INFO 2025-01-30 07:13:20,348 runserver HTTP GET /dashboard/ 200 [0.01, 127.0.0.1:34694]
INFO 2025-01-30 07:13:20,372 runserver HTTP GET /static/dashboard/main/main.css 200 [0.01, 127.0.0.1:34694]
INFO 2025-01-30 07:13:20,373 runserver HTTP GET /static/dashboard/main/main.js 200 [0.00, 127.0.0.1:34704]
INFO 2025-01-30 07:13:20,544 runserver WebSocket HANDSHAKING /ws/notifyFR/ [127.0.0.1:34720]
DEBUG 2025-01-30 07:13:20,546 utils (0.000)
SELECT VERSION(),
@@sql_mode,
@@default_storage_engine,
@@sql_auto_is_null,
@@lower_case_table_names,
CONVERT_TZ('2001-01-01 01:00:00', 'UTC', 'UTC') IS NOT NULL
; args=None; alias=default
DEBUG 2025-01-30 07:13:20,546 utils (0.000) SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; args=None; alias=default
DEBUG 2025-01-30 07:13:20,546 utils (0.000) SELECT `django_session`.`session_key`, `django_session`.`session_data`, `django_session`.`expire_date` FROM `django_session` WHERE (`django_session`.`expire_date` > '2025-01-30 07:13:20.544422' AND `django_session`.`session_key` = 'ct5m448zca7p1vczx1yeawezj5b48zc7') LIMIT 21; args=('2025-01-30 07:13:20.544422', 'ct5m448zca7p1vczx1yeawezj5b48zc7'); alias=default
DEBUG 2025-01-30 07:13:20,546 utils (0.000) SELECT `src_user`.`last_login`, `src_user`.`userID`, `src_user`.`username`, `src_user`.`email`, `src_user`.`password`, `src_user`.`profileImage`, `src_user`.`created_at`, `src_user`.`notificationSFX`, `src_user`.`is_active`, `src_user`.`is_admin` FROM `src_user` WHERE `src_user`.`userID` = '3f1e0afe64ac4ce4b5e3dd5cb4b4555e' LIMIT 21; args=('3f1e0afe64ac4ce4b5e3dd5cb4b4555e',); alias=default
---- Jerry Kole with a userID of 3f1e0afe-64ac-4ce4-b5e3-dd5cb4b4555e is in the group noti_3f1e0afe-64ac-4ce4-b5e3-dd5cb4b4555e.
INFO 2025-01-30 07:13:20,547 runserver WebSocket CONNECT /ws/notifyFR/ [127.0.0.1:34720]
INFO 2025-01-30 07:13:20,629 runserver HTTP GET /static/dummyUser.png 200 [0.00, 127.0.0.1:34694]
INFO 2025-01-30 07:13:20,632 runserver HTTP GET /uploads/profiles/user_3f1e0afe-64ac-4ce4-b5e3-dd5cb4b4555e.jpeg 200 [0.01, 127.0.0.1:34704]
DEBUG 2025-01-30 07:13:21,229 autoreload File /home/default/NEA-Project/CrypTalk/venv/lib/python3.12/site-packages/django/contrib/staticfiles/storage.py first seen with mtime 1735489103.2265627
DEBUG 2025-01-30 07:13:21,230 autoreload File /home/default/NEA-Project/CrypTalk/venv/lib/python3.12/site-packages/django/contrib/messages/storage/session.py first seen with mtime 1735489103.1272864
DEBUG 2025-01-30 07:13:21,230 autoreload File /home/default/NEA-Project/CrypTalk/venv/lib/python3.12/site-packages/django/contrib/sessions/serializers.py first seen with mtime 1735489103.1769245
DEBUG 2025-01-30 07:13:21,230 autoreload File /home/default/NEA-Project/CrypTalk/venv/lib/python3.12/site-packages/django/contrib/messages/storage/fallback.py first seen with mtime 1735489103.1272864
DEBUG 2025-01-30 07:13:21,230 autoreload File /home/default/NEA-Project/CrypTalk/venv/lib/python3.12/site-packages/django/contrib/messages/context_processors.py first seen with mtime 1735489103.1272864
DEBUG 2025-01-30 07:13:21,230 autoreload File /home/default/NEA-Project/CrypTalk/venv/lib/python3.12/site-packages/django/contrib/auth/context_processors.py first seen with mtime 1735489102.978356
DEBUG 2025-01-30 07:13:21,231 autoreload File /home/default/NEA-Project/CrypTalk/venv/lib/python3.12/site-packages/django/contrib/messages/storage/cookie.py first seen with mtime 1735489103.1272864
DEBUG 2025-01-30 07:13:21,231 autoreload File /home/default/NEA-Project/CrypTalk/venv/lib/python3.12/site-packages/django/template/context_processors.py first seen with mtime 1735489103.2662733
DEBUG 2025-01-30 07:13:21,444 utils (0.000)
SELECT VERSION(),
@@sql_mode,
@@default_storage_engine,
@@sql_auto_is_null,
@@lower_case_table_names,
CONVERT_TZ('2001-01-01 01:00:00', 'UTC', 'UTC') IS NOT NULL
; args=None; alias=default
DEBUG 2025-01-30 07:13:21,454 utils (0.010) SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; args=None; alias=default
DEBUG 2025-01-30 07:13:21,463 utils (0.008) SELECT `django_session`.`session_key`, `django_session`.`session_data`, `django_session`.`expire_date` FROM `django_session` WHERE (`django_session`.`expire_date` > '2025-01-30 07:13:21.437975' AND `django_session`.`session_key` = 'tqmmsutki3rybreawpxto466cz2ox9yq') LIMIT 21; args=('2025-01-30 07:13:21.437975', 'tqmmsutki3rybreawpxto466cz2ox9yq'); alias=default
DEBUG 2025-01-30 07:13:21,463 utils (0.000) SELECT `src_user`.`last_login`, `src_user`.`userID`, `src_user`.`username`, `src_user`.`email`, `src_user`.`password`, `src_user`.`profileImage`, `src_user`.`created_at`, `src_user`.`notificationSFX`, `src_user`.`is_active`, `src_user`.`is_admin` FROM `src_user` WHERE `src_user`.`userID` = '16bb0918aa2244e388648b639a915190' LIMIT 21; args=('16bb0918aa2244e388648b639a915190',); alias=default
DEBUG 2025-01-30 07:13:21,464 utils (0.000) SELECT `api_friendrequest`.`requestID`, `api_friendrequest`.`sender`, `api_friendrequest`.`receiver` FROM `api_friendrequest` WHERE `api_friendrequest`.`receiver` = '16bb0918aa2244e388648b639a915190'; args=('16bb0918aa2244e388648b639a915190',); alias=default
INFO 2025-01-30 07:13:21,466 runserver HTTP GET /dashboard/ 200 [0.03, 127.0.0.1:34724]
INFO 2025-01-30 07:13:21,485 runserver HTTP GET /static/dashboard/main/main.css 200 [0.00, 127.0.0.1:34724]
INFO 2025-01-30 07:13:21,487 runserver HTTP GET /static/dashboard/main/main.js 200 [0.00, 127.0.0.1:34732]
INFO 2025-01-30 07:13:21,625 runserver HTTP GET /static/dummyUser.png 200 [0.00, 127.0.0.1:34724]
INFO 2025-01-30 07:13:21,628 runserver HTTP GET /uploads/profiles/user_16bb0918-aa22-44e3-8864-8b639a915190.jpeg 200 [0.01, 127.0.0.1:34732]
INFO 2025-01-30 07:13:21,638 runserver WebSocket HANDSHAKING /ws/notifyFR/ [127.0.0.1:34742]
DEBUG 2025-01-30 07:13:21,641 utils (0.000) SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; args=None; alias=default
DEBUG 2025-01-30 07:13:21,650 utils (0.009) SELECT `django_session`.`session_key`, `django_session`.`session_data`, `django_session`.`expire_date` FROM `django_session` WHERE (`django_session`.`expire_date` > '2025-01-30 07:13:21.638928' AND `django_session`.`session_key` = 'tqmmsutki3rybreawpxto466cz2ox9yq') LIMIT 21; args=('2025-01-30 07:13:21.638928', 'tqmmsutki3rybreawpxto466cz2ox9yq'); alias=default
DEBUG 2025-01-30 07:13:21,650 utils (0.000) SELECT `src_user`.`last_login`, `src_user`.`userID`, `src_user`.`username`, `src_user`.`email`, `src_user`.`password`, `src_user`.`profileImage`, `src_user`.`created_at`, `src_user`.`notificationSFX`, `src_user`.`is_active`, `src_user`.`is_admin` FROM `src_user` WHERE `src_user`.`userID` = '16bb0918aa2244e388648b639a915190' LIMIT 21; args=('16bb0918aa2244e388648b639a915190',); alias=default
---- Frank with a userID of 16bb0918-aa22-44e3-8864-8b639a915190 is in the group noti_16bb0918-aa22-44e3-8864-8b639a915190.
INFO 2025-01-30 07:13:21,651 runserver WebSocket CONNECT /ws/notifyFR/ [127.0.0.1:34742]
DEBUG 2025-01-30 07:13:26,032 utils (0.000)
SELECT VERSION(),
@@sql_mode,
@@default_storage_engine,
@@sql_auto_is_null,
@@lower_case_table_names,
CONVERT_TZ('2001-01-01 01:00:00', 'UTC', 'UTC') IS NOT NULL
; args=None; alias=default
DEBUG 2025-01-30 07:13:26,033 utils (0.000) SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; args=None; alias=default
DEBUG 2025-01-30 07:13:26,033 utils (0.000) SELECT `django_session`.`session_key`, `django_session`.`session_data`, `django_session`.`expire_date` FROM `django_session` WHERE (`django_session`.`expire_date` > '2025-01-30 07:13:26.031345' AND `django_session`.`session_key` = 'ct5m448zca7p1vczx1yeawezj5b48zc7') LIMIT 21; args=('2025-01-30 07:13:26.031345', 'ct5m448zca7p1vczx1yeawezj5b48zc7'); alias=default
DEBUG 2025-01-30 07:13:26,033 utils (0.000) SELECT `src_user`.`last_login`, `src_user`.`userID`, `src_user`.`username`, `src_user`.`email`, `src_user`.`password`, `src_user`.`profileImage`, `src_user`.`created_at`, `src_user`.`notificationSFX`, `src_user`.`is_active`, `src_user`.`is_admin` FROM `src_user` WHERE `src_user`.`userID` = '3f1e0afe64ac4ce4b5e3dd5cb4b4555e' LIMIT 21; args=('3f1e0afe64ac4ce4b5e3dd5cb4b4555e',); alias=default
DEBUG 2025-01-30 07:13:26,034 utils (0.000) SELECT 1 AS `a` FROM `src_user` WHERE `src_user`.`username` = 'Frank' LIMIT 1; args=(1, 'Frank'); alias=default
DEBUG 2025-01-30 07:13:26,034 utils (0.000) SELECT `src_user`.`userID` FROM `src_user` WHERE `src_user`.`username` = 'Frank' LIMIT 1; args=('Frank',); alias=default
INFO 2025-01-30 07:13:26,035 runserver HTTP GET /api/get-userid?username=Frank 200 [0.01, 127.0.0.1:34756]
DEBUG 2025-01-30 07:13:26,043 utils (0.000)
SELECT VERSION(),
@@sql_mode,
@@default_storage_engine,
@@sql_auto_is_null,
@@lower_case_table_names,
CONVERT_TZ('2001-01-01 01:00:00', 'UTC', 'UTC') IS NOT NULL
; args=None; alias=default
DEBUG 2025-01-30 07:13:26,043 utils (0.000) SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; args=None; alias=default
DEBUG 2025-01-30 07:13:26,052 utils (0.009) SELECT `django_session`.`session_key`, `django_session`.`session_data`, `django_session`.`expire_date` FROM `django_session` WHERE (`django_session`.`expire_date` > '2025-01-30 07:13:26.041177' AND `django_session`.`session_key` = 'ct5m448zca7p1vczx1yeawezj5b48zc7') LIMIT 21; args=('2025-01-30 07:13:26.041177', 'ct5m448zca7p1vczx1yeawezj5b48zc7'); alias=default
DEBUG 2025-01-30 07:13:26,053 utils (0.000) SELECT `src_user`.`last_login`, `src_user`.`userID`, `src_user`.`username`, `src_user`.`email`, `src_user`.`password`, `src_user`.`profileImage`, `src_user`.`created_at`, `src_user`.`notificationSFX`, `src_user`.`is_active`, `src_user`.`is_admin` FROM `src_user` WHERE `src_user`.`userID` = '3f1e0afe64ac4ce4b5e3dd5cb4b4555e' LIMIT 21; args=('3f1e0afe64ac4ce4b5e3dd5cb4b4555e',); alias=default
Hello {'receiver': '16bb0918-aa22-44e3-8864-8b639a915190'}
DEBUG 2025-01-30 07:13:26,054 utils (0.000) SELECT 1 AS `a` FROM `api_friendrequest` WHERE (`api_friendrequest`.`receiver` = '16bb0918aa2244e388648b639a915190' AND `api_friendrequest`.`sender` = '3f1e0afe64ac4ce4b5e3dd5cb4b4555e') LIMIT 1; args=(1, '16bb0918aa2244e388648b639a915190', '3f1e0afe64ac4ce4b5e3dd5cb4b4555e'); alias=default
DEBUG 2025-01-30 07:13:26,054 utils (0.000) SELECT 1 AS `a` FROM `api_friendrequest` WHERE (`api_friendrequest`.`receiver` = '3f1e0afe64ac4ce4b5e3dd5cb4b4555e' AND `api_friendrequest`.`sender` = '16bb0918aa2244e388648b639a915190') LIMIT 1; args=(1, '3f1e0afe64ac4ce4b5e3dd5cb4b4555e', '16bb0918aa2244e388648b639a915190'); alias=default
fr made
DEBUG 2025-01-30 07:13:26,063 utils (0.009) INSERT INTO `api_friendrequest` (`requestID`, `sender`, `receiver`) VALUES ('7cfe7ab1d82b46dfb1d0f120762adbe7', '3f1e0afe64ac4ce4b5e3dd5cb4b4555e', '16bb0918aa2244e388648b639a915190'); args=('7cfe7ab1d82b46dfb1d0f120762adbe7', '3f1e0afe64ac4ce4b5e3dd5cb4b4555e', '16bb0918aa2244e388648b639a915190'); alias=default
DEBUG 2025-01-30 07:13:26,064 utils (0.000) UPDATE `api_friendrequest` SET `sender` = '3f1e0afe64ac4ce4b5e3dd5cb4b4555e', `receiver` = '16bb0918aa2244e388648b639a915190' WHERE `api_friendrequest`.`requestID` = '7cfe7ab1d82b46dfb1d0f120762adbe7'; args=('3f1e0afe64ac4ce4b5e3dd5cb4b4555e', '16bb0918aa2244e388648b639a915190', '7cfe7ab1d82b46dfb1d0f120762adbe7'); alias=default
INFO 2025-01-30 07:13:26,066 runserver HTTP POST /api/add-contact 201 [0.03, 127.0.0.1:34756]
{"requestID":"7cfe7ab1-d82b-46df-b1d0-f120762adbe7"}
DEBUG 2025-01-30 07:13:26,071 utils (0.000) SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; args=None; alias=default
DEBUG 2025-01-30 07:13:26,071 utils (0.000) SELECT `api_friendrequest`.`requestID`, `api_friendrequest`.`sender`, `api_friendrequest`.`receiver` FROM `api_friendrequest` WHERE `api_friendrequest`.`requestID` = '7cfe7ab1d82b46dfb1d0f120762adbe7' LIMIT 21; args=('7cfe7ab1d82b46dfb1d0f120762adbe7',); alias=default
DEBUG 2025-01-30 07:13:26,072 utils (0.000) SELECT `src_user`.`last_login`, `src_user`.`userID`, `src_user`.`username`, `src_user`.`email`, `src_user`.`password`, `src_user`.`profileImage`, `src_user`.`created_at`, `src_user`.`notificationSFX`, `src_user`.`is_active`, `src_user`.`is_admin` FROM `src_user` WHERE `src_user`.`userID` = '16bb0918aa2244e388648b639a915190' LIMIT 21; args=('16bb0918aa2244e388648b639a915190',); alias=default
DEBUG 2025-01-30 07:13:26,072 utils (0.000) SELECT `src_user`.`last_login`, `src_user`.`userID`, `src_user`.`username`, `src_user`.`email`, `src_user`.`password`, `src_user`.`profileImage`, `src_user`.`created_at`, `src_user`.`notificationSFX`, `src_user`.`is_active`, `src_user`.`is_admin` FROM `src_user` WHERE `src_user`.`userID` = '3f1e0afe64ac4ce4b5e3dd5cb4b4555e' LIMIT 21; args=('3f1e0afe64ac4ce4b5e3dd5cb4b4555e',); alias=default
------------- TRUTH TABLE -------------
Target Group: noti_16bb0918-aa22-44e3-8864-8b639a915190
Receiver: Frank
Sender: Jerry Kole
Own Group Name: noti_3f1e0afe-64ac-4ce4-b5e3-dd5cb4b4555e
---------------- OUTPUTS ---------------
Sending to...noti_16bb0918-aa22-44e3-8864-8b639a915190
Succesfully sent message to group
I think trying redis for channel layers may show something.
Looking at this from a different perspective - how are you testing this?
Are you using two different browsers (e.g. Chrome and Firefox) for the two connections?
Or are you trying to test this using two tabs on the same browser? If this is the case, then that is part of the problem. There’s a lot of shared state between browser tabs that will cause problems with things like this.
You need to test this using either two different browsers (and not just separate windows of the same browser), or one window in “normal” mode and the other in “private” or “incognito” mode.
Yes I’m using firefox in one “normal” window and another in “private”.
Then yes, I would suggest moving to redis as the next step. If nothing else, you’ll have more tools available to you for diagnosing this. (You could use tcpdump / wireshark to monitor the traffic between redis and Daphne, the redis-cli to explore the contents in redis, and redis’ logging to get more details about what it’s doing internally.)
I tried fetching the group’s key a couple of times using ZRANGE
, intially it returned nothing:
127.0.0.1:6379> ZRANGE "asgi:group:noti_16bb0918-aa22-44e3-8864-8b639a915190" 0 1
(empty array)
127.0.0.1:6379> ZRANGE asgi:group:noti_16bb0918-aa22-44e3-8864-8b639a915190 0 1
(empty array)
I decided to put the parameters outside the async-to-sync wrapper:
async_to_sync(self.channel_layer.group_add)(self.group_name, self.channel_name)
I did the same for discarding the group - and the query is finally returning the channel:
127.0.0.1:6379> ZRANGE asgi:group:noti_16bb0918-aa22-44e3-8864-8b639a915190 0 1
1) "specific.cbfd3047e6b14f88ab9e9734428e654a!3f3a810e971842c0b5cc618fa9eb161b"
127.0.0.1:6379> ZRANGE asgi:group:noti_16bb0918-aa22-44e3-8864-8b639a915190 0 1
1) "specific.cbfd3047e6b14f88ab9e9734428e654a!3f3a810e971842c0b5cc618fa9eb161b"
The consumer is also receiving the message now. I do vaguely remember trying this change with InMemoryChannelLayer
, but it didn’t work for that.
I checked for that - and confirmed it was correct for the group_send
. I didn’t think to check the group_add
.
But yes, this is true for all uses of async_to_sync
. You need to wrap the function and not the output from the function.