I've noticed that someone could easily crash my website using a simple javascript while loop that continuously sends stuff like so:
while(true) {
websocket.send(JSON.stringify({}));
}
I'm using nginx which passes ws-requests to daphne which in turn talks to django-channels. This is the relevant configuration part:
location /ws/ {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_redirect off;
limit_conn addr 10;
proxy_pass http://daphne;
}
Is there any easy way to prevent this? An upper limit for the datastream would be super. The websocket connection is used for things that may send several messages within a few (hundred?) milliseconds (WebRTC and game related stuff).