Error log on server side every time a WS is opened
See original GitHub issueWhen any new WebSocket connection is opened, on the server trace I see this error message about the non origin header...
, but still it works as intended, the WS workflow happens as you can see with the WebSocket HANDSHAKING /ws-notifications/ [127.0.0.1:45222]
:
$ python manage.py runserver
Performing system checks...
System check identified no issues (0 silenced).
April 06, 2018 - 15:10:23
Django version 2.0.4, using settings 'config.settings.local'
Starting ASGI/Channels development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
2018-04-06 15:10:23,742 - INFO - server - HTTP/2 support not enabled (install the http2 and tls Twisted extras)
2018-04-06 15:10:23,742 - INFO - server - Configuring endpoint tcp:port=8000:interface=127.0.0.1
2018-04-06 15:10:23,743 - INFO - server - Listening on TCP address 127.0.0.1:8000
non origin header: b'host'
non origin header: b'user-agent'
non origin header: b'accept'
non origin header: b'accept-language'
non origin header: b'accept-encoding'
non origin header: b'sec-websocket-version'
got origin header, val b'http://127.0.0.1:8000'
nuhost: '127.0.0.1'
non origin header: b'sec-websocket-protocol'
non origin header: b'sec-websocket-extensions'
non origin header: b'sec-websocket-key'
non origin header: b'cookie'
non origin header: b'connection'
non origin header: b'pragma'
non origin header: b'cache-control'
non origin header: b'upgrade'
origin header: 127.0.0.1
[2018/04/06 15:10:24] WebSocket HANDSHAKING /ws-notifications/ [127.0.0.1:45222]
[2018/04/06 15:10:24] WebSocket CONNECT /ws-notifications/ [127.0.0.1:45222]
I just used the consumer provided in the tutorial to see it working:
import json
from channels.generic.websocket import WebsocketConsumer
class NotificationsConsumer(WebsocketConsumer):
"""Consumer to manage WebSocket connections for the Notification app,
called when the websocket is handshaking as part of initial connection.
"""
def connect(self):
if self.scope["user"].is_anonymous:
# Reject the connection
self.close()
else:
# Accept the connection
self.accept()
def disconnect(self, close_code):
pass
def receive(self, text_data):
text_data_json = json.loads(text_data)
message = text_data_json['message']
self.send(text_data=json.dumps({
'message': message
}))
And this is the JS client, also a minimal one:
$(function () {
// Correctly decide between ws:// and wss://
var ws_scheme = window.location.protocol == "https:" ? "wss" : "ws";
var ws_path = ws_scheme + '://' + window.location.host + "/ws-notifications/";
var webSocket = new channels.WebSocketBridge();
webSocket.connect(ws_path);
// Helpful debugging
webSocket.socket.onopen = function () {
console.log("Connected to " + ws_path + " stream");
webSocket.send({
"message": "this is the message because you connected to " + ws_path,
})
};
webSocket.socket.onclose = function () {
console.error("Disconnected from " + ws_path + " stream");
};
webSocket.listen(function(event) {
$("#notifications").addClass("btn-danger")
});
});
I’m unable to find why this is happening.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Logging Errors in Client-Side Applications - SitePoint
Lukas White walks through the various options for logging errors in the browser and solutions for persisting error data to the server for ......
Read more >AD FS Troubleshooting - Auditing Events and Logging
Open Event Viewer and expand Applications and Services Log. Right-click on Applications and Services Log, click View and select Show Analytic ...
Read more >Troubleshooting : WebSphere start/stop common issues - IBM
This document contains troubleshooting information for problems with WebSphere® Application Server start and stop operations.
Read more >How to track client-side JavaScript errors - Format Express Blog
Collect JavaScript errors; Set up a WebSocket - client-side ... Here give some time to the WS to get ready ... Open log...
Read more >Collecting a WorkSpaces support log bundle for debugging
Choose OK and close the Windows Registry Editor. PCoIP server-side logs. All of the PCoIP components write their log files into one of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
They’ll be in the next release when I get to doing it, I am taking a few weeks off from most coding. The next one is big and so needs lots of prep in terms of release notes.
The string
non origin header
doesn’t appear in either the Channels or Daphne code base so it’s not coming from us. If you can find where the string is in the code of various libraries that will help work out where it’s coming from.