Opened 4 years ago
Closed 4 years ago
#31903 closed Bug (invalid)
WebSocket OSError: headers already sent.
Reported by: | liu,guoshun | Owned by: | nobody |
---|---|---|---|
Component: | Core (Other) | Version: | 2.0 |
Severity: | Normal | Keywords: | OSError: headers already sent |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
1.uwsgi --http 0.0.0.0:8066 --module toraji.wsgi --master --processes 1 --threads 8 --http-websockets
*** Starting uWSGI 2.0.18 (64bit) on [Wed Aug 19 09:28:05 2020] *** compiled with version: 4.4.7 20120313 (Red Hat 4.4.7-11) on 15 July 2020 02:09:52 os: Linux-2.6.32-504.23.4.el6.x86_64 #1 SMP Tue Jun 9 20:57:37 UTC 2015 nodename: toraji_dba machine: x86_64 clock source: unix pcre jit disabled detected number of CPU cores: 4 current working directory: /apps/svr/shun/toraji detected binary path: /usr/local/bin/uwsgi uWSGI running as root, you can use --uid/--gid/--chroot options *** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** your processes number limit is 65536 your memory page size is 4096 bytes detected max file descriptor number: 1024 lock engine: pthread robust mutexes thunder lock: disabled (you can enable it with --thunder-lock) uWSGI http bound on 0.0.0.0:8066 fd 4 uwsgi socket 0 bound to TCP address 127.0.0.1:41844 (port auto-assigned) fd 3 uWSGI running as root, you can use --uid/--gid/--chroot options *** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** Python version: 3.6.0 (default, Dec 8 2018, 21:49:17) [GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] Python main interpreter initialized at 0x15540e0 uWSGI running as root, you can use --uid/--gid/--chroot options *** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** python threads support enabled your server socket listen backlog is limited to 100 connections your mercy for graceful operations on workers is 60 seconds mapped 292224 bytes (285 KB) for 8 cores *** Operational MODE: threaded *** WSGI app 0 (mountpoint='') ready in 2 seconds on interpreter 0x15540e0 pid: 23945 (default app) uWSGI running as root, you can use --uid/--gid/--chroot options *** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** *** uWSGI is running in multiple interpreter mode *** spawned uWSGI master process (pid: 23945) spawned uWSGI worker 1 (pid: 23950, cores: 8) spawned uWSGI http 1 (pid: 23951)
2.Django as backend
cat views_os.py
import json import logging logger = logging.getLogger(__name__) import uwsgi from django.http import HttpResponse def test_socket_api(request): uwsgi.websocket_handshake() data = uwsgi.websocket_recv() data = data.decode() data = json.loads(data) logger.debug(data) os_cmd = "/tmp/mha.sh test socket" #test cmd logger.info("##mha socket test cmd:%s",os_cmd) uwsgi.websocket_send(os_cmd) logger.info("done.") return HttpResponse(None)
- Got errors :
2020-08-19 09:32:52,029 [uWSGIWorker1Core0:139922668804032] [mysqlha.views_os 14] [DEBUG]- {'a': 1} 2020-08-19 09:32:52,030 [uWSGIWorker1Core0:139922668804032] [mysqlha.views_os 16] [INFO]- ##mha socket test cmd:/tmp/mha.sh test socket 2020-08-19 09:32:52,031 [uWSGIWorker1Core0:139922668804032] [mysqlha.views_os 19] [INFO]- done. Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/django/core/handlers/wsgi.py", line 154, in call start_response(status, response_headers) OSError: headers already sent [pid: 24091|app: 0|req: 1/1] 10.107.68.57 () {48 vars in 817 bytes} [Wed Aug 19 09:32:49 2020] GET /mysqlha/test_socket_api => generated 25 bytes in 2080 msecs (HTTP/1.1 101) 4 headers in 184 bytes (0 switches on core 0)
Change History (3)
comment:1 by , 4 years ago
Type: | Uncategorized → Bug |
---|
comment:2 by , 4 years ago
Description: | modified (diff) |
---|
comment:3 by , 4 years ago
Component: | Error reporting → Core (Other) |
---|---|
Description: | modified (diff) |
Owner: | set to |
Resolution: | → invalid |
Status: | new → closed |
Summary: | WebSocket OSError: headers already sent → WebSocket OSError: headers already sent. |
Django itself doesn't support WebSockets.
Closing per TicketClosingReasons/UseSupportChannels.
Note:
See TracTickets
for help on using tickets.
similar to this issue : https://github.com/miguelgrinberg/Flask-SocketIO/issues/377