Websocket,python - 现有连接被远程主机强制关闭(django-channels)

时间:2017-06-24 18:49:37

标签: python django websocket redis django-channels

所以我收到了这篇文章标题中描述的错误。这是完整的追溯:

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

我正在运行redis,manage.py runserver正在运行,而我正在使用django-channels。这是我第一次使用websockets。任何人都可以帮忙,让我知道什么是错的吗?

0 个答案:

没有答案