Bearle / django-private-chat

(Deprecated - Please check out https://github.com/Bearle/django_private_chat2) Django one-to-one Websocket-based Asyncio-handled chat, developed by Bearle team
ISC License
424 stars 132 forks source link

Users report ERR_CONNECTION_RESET #31

Open dmonn opened 5 years ago

dmonn commented 5 years ago

Description

I have django-private-chat deployed in production. Users sent me feedback that they get the following error sometimes (it seems to happen in corporate networks only)

WebSocket connection to XY failed: Error in connection establishment: net::ERR_CONNECTION_RESET.

The chat works fine in 90% of the cases, but this error seems to come up from time to time. Chat is embedded in an iframe (same domain), this could add to the problem.

What I Did

Made sure the chat server is running, tested the chat in my home network - seems to work fine.

Users report:

WebSocket connection to XY failed: Error in connection establishment: net::ERR_CONNECTION_RESET.

delneg commented 5 years ago

Can you probably try using a newer version of websockets lib ? Seems to be similar to this issue: https://github.com/django/channels/issues/549

dmonn commented 5 years ago

Let's try!

dmonn commented 5 years ago

Note @delneg, the upgrade worked, but the issue still seems to persist. I'm not sure about how to locally reproduce this though. It seems to happen in restrictive corporate environments.

delneg commented 5 years ago

Hello again, what do you mean by 'upgrade worked' ? Please provide more details. Also, you could try to implement re-connection by handling 'connection reset' events in javascript and estabilishing a new websocket connection.

dmonn commented 5 years ago

The upgrade of websockets didn't make any problems. I'm already doing reconnects with https://github.com/joewalnes/reconnecting-websocket.

Again, this only seems to occur in corporate networks.

alisarmad commented 4 years ago

Hi everyone, I am also facing WebSocket connection problem since last couple of days. Error Description "_websocket.js:18 WebSocket connection to 'ws://127.0.0.1:8000/ws' failed: Error in connection establishment: net::ERR_CONNECTIONREFUSED"

Browser Console Error line Number 18, (connect @ websocket.js:18) contains following code const path = 'ws://127.0.0.1:8000/ws'; this.socketRef = new WebSocket(path); this.socketRef.onopen = () => { console.log('WebSocket open'); }; socketRef.onclose @ websocket.js:33 `` websocket.js:29 undefined websocket.js:32 WebSocket closed let's reopen 32Chat.js:27 wait for connection...

Detail Django version : 2.2 Front-end with react Using Parceljs

Websocket was working fine with Bootstrap and Django Channels, I am trying to develop one to one chat application with React front-end and Python Backend, When I tried to implement the WebSocket in react then it is giving me above mentioned error.

What I have tried Django Channels Issue(549)

I am new to Websocket and React, Any help will be appreciated.

alisarmad commented 4 years ago

I have solved the above error, actually there was my mistake, I forgot to run both servers(Backend: [python manage.py runserver], and frontend react [npm start]).

Therefore, make sure we have both servers running.