couldn’t find any registered log request from daphne.service:
daphne.service - WebSocket Daphne Service
Loaded: loaded (/etc/systemd/system/daphne.service; disabled; preset: enabled)
Active: active (running) since Wed 2024-01-10 14:06:13 UTC; 12h ago
Main PID: 141270 (python)
Tasks: 3 (limit: 2308)
Memory: 84.1M
CPU: 23.832s
CGroup: /system.slice/daphne.service
└─141270 /home/taskitly/taskily/venv/bin/python /home/taskitly/taskily/venv/bin/daphne -e ssl:8001:p>
Jan 10 14:06:13 taskitly.com systemd[1]: Started daphne.service - WebSocket Daphne Service.
Jan 10 14:06:14 taskitly.com python[141270]: 2024-01-10 15:06:14,974 INFO Starting server at ssl:8001:private>
Jan 10 14:06:14 taskitly.com python[141270]: 2024-01-10 15:06:14,976 INFO HTTP/2 support enabled
Jan 10 14:06:14 taskitly.com python[141270]: 2024-01-10 15:06:14,976 INFO Configuring endpoint ssl:8001:priva>
Jan 10 14:06:14 taskitly.com python[141270]: 2024-01-10 15:06:14,984 INFO Listening on TCP address 0.0.0.0:80>
~
~
here’s a python script test:
import websocket
import threading
import time
def on_message(ws, message):
print(f"Received message: {message}")
def on_error(ws, error):
print(f"WebSocket error: {error}")
def on_close(ws, close_status_code, close_msg):
print("WebSocket closed")
def on_open(ws):
def send_heartbeat():
while True:
ws.send("Heartbeat")
time.sleep(5)
# Start a thread to send periodic heartbeats
threading.Thread(target=send_heartbeat, daemon=True).start()
if __name__ == "__main__":
websocket.enableTrace(True)
# Replace 'wss://example.com/socket' with your WebSocket URL
ws_url = "wss://taskitly.com/notification"
ws = websocket.WebSocketApp(
ws_url,
on_message=on_message,
on_error=on_error,
on_close=on_close,
)
ws.on_open = on_open
# Run the WebSocket in a separate thread
ws_thread = threading.Thread(target=ws.run_forever, daemon=True)
ws_thread.start()
# Keep the main thread running to simulate an application
while True:
time.sleep(1)
The Response:
-- request header ---
GET /notification HTTP/1.1
Upgrade: websocket
Host: taskitly.com
Origin: https://taskitly.com
Sec-WebSocket-Key: 01sNGWjyUWWPD6B2EDTSxQ==
Sec-WebSocket-Version: 13
Connection: Upgrade
-----------------------
--- response header ---
HTTP/1.1 404 Not Found
Server: nginx/1.24.0 (Ubuntu)
Date: Thu, 11 Jan 2024 02:37:31 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 179
Connection: keep-alive
X-Frame-Options: DENY
Vary: origin
access-control-allow-origin: *
X-Content-Type-Options: nosniff
Referrer-Policy: same-origin
Cross-Origin-Opener-Policy: same-origin
-----------------------
WebSocket error: Handshake status 404 Not Found -+-+- {'server': 'nginx/1.24.0 (Ubuntu)', 'date': 'Thu, 11 Jan 2024 02:37:31 GMT', 'content-type': 'text/html; charset=utf-8', 'content-length': '179', 'connection': 'keep-alive', 'x-frame-options': 'DENY', 'vary': 'origin', 'access-control-allow-origin': '*', 'x-content-type-options': 'nosniff', 'referrer-policy': 'same-origin', 'cross-origin-opener-policy': 'same-origin'} -+-+- b'\n<!doctype html>\n<html lang="en">\n<head>\n <title>Not Found</title>\n</head>\n<body>\n <h1>Not Found</h1><p>The requested resource was not found on this server.</p>\n</body>\n</html>\n'
Handshake status 404 Not Found -+-+- {'server': 'nginx/1.24.0 (Ubuntu)', 'date': 'Thu, 11 Jan 2024 02:37:31 GMT', 'content-type': 'text/html; charset=utf-8', 'content-length': '179', 'connection': 'keep-alive', 'x-frame-options': 'DENY', 'vary': 'origin', 'access-control-allow-origin': '*', 'x-content-type-options': 'nosniff', 'referrer-policy': 'same-origin', 'cross-origin-opener-policy': 'same-origin'} -+-+- b'\n<!doctype html>\n<html lang="en">\n<head>\n <title>Not Found</title>\n</head>\n<body>\n <h1>Not Found</h1><p>The requested resource was not found on this server.</p>\n</body>\n</html>\n' - goodbye
WebSocket closed