Websocket, django-channels - an existing connection was forcibly closed by the remote host

154 views
Skip to first unread message

Mike Johnson Jr

unread,
Jun 25, 2017, 2:35:28 PM6/25/17
to Django developers (Contributions to Django itself)

So I'm getting the error as described in the title of this post.

I'm following this tutorial: https://gearheart.io/blog/creating-a-chat-with-django-channels/

Here's the full traceback:

In [1]: import websocket

In [2]: ws = websocket.WebSocket()

In [3]: ws.connect("ws://localhost:8000")
---------------------------------------------------------------------------
error                                     Traceback (most recent call last)
<ipython-input-3-43b98f503495> in <module>()
----> 1 ws.connect("ws://localhost:8000")

c:\Python27\lib\site-packages\websocket\_core.pyc in connect(self, url, **options)
    212
    213         try:
--> 214             self.handshake_response = handshake(self.sock, *addrs, **options)
    215             self.connected = True
    216         except:

c:\Python27\lib\site-packages\websocket\_handshake.pyc in handshake(sock, hostname, por
t, resource, **options)
     67     dump("request header", header_str)
     68
---> 69     status, resp = _get_resp_headers(sock)
     70     success, subproto = _validate(resp, key, options.get("subprotocols"))
     71     if not success:

c:\Python27\lib\site-packages\websocket\_handshake.pyc in _get_resp_headers(sock, succe
ss_status)
    125
    126 def _get_resp_headers(sock, success_status=101):
--> 127     status, resp_headers = read_headers(sock)
    128     if status != success_status:
    129         raise WebSocketBadStatusException("Handshake status %d", status)

c:\Python27\lib\site-packages\websocket\_http.pyc in read_headers(sock)
    224
    225     while True:
--> 226         line = recv_line(sock)
    227         line = line.decode('utf-8').strip()
    228         if not line:

c:\Python27\lib\site-packages\websocket\_socket.pyc in recv_line(sock)
     99     line = []
    100     while True:
--> 101         c = recv(sock, 1)
    102         line.append(c)
    103         if c == six.b("\n"):

c:\Python27\lib\site-packages\websocket\_socket.pyc in recv(sock, bufsize)
     78
     79     try:
---> 80         bytes_ = sock.recv(bufsize)
     81     except socket.timeout as e:
     82         message = extract_err_message(e)

error: [Errno 10054] An existing connection was forcibly closed by the remote host

I have redis running, manage.py runserver running, and I'm using django-channels. This is my first time working with websockets. Can anyone help out and let me know what's wrong?

Andrew Godwin

unread,
Jun 25, 2017, 5:26:36 PM6/25/17
to Django developers (Contributions to Django itself)
Please don't cross-post questions to both mailing lists. I will answer this on django-users after the weekend.

Andrew

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscribe@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/4a44de8f-3c64-4eb7-a71d-d575c192b72f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages