Python2.7+Django+dwebsocket報錯error: [Errno 10053]


找到dwebsoket:

\venv\Lib\site-packages\dwebsocket\backends\default\protocols.py
修改如下

修改過后又報錯:
Django使用dwebsocket來通信,服務器報錯[Error 10038]

找了好長時間沒有找到解決方案,最后自己多次嘗試,修改代碼,解決:
報錯影響功能的正常使用,雖然不知道什么原因,但是加入對消息的讀取就不再會報錯了



@require_websocket
def ws_connect(request):
    try:
        if request.is_websocket():
            print 1
            # request.websocket.send("1111".decode('utf-8'))
            for message in request.websocket:
                # request.websocket.send(message)  # 發送消息到客戶端
                print message
            pass
        else:
            print 2222
            return HttpResponse("ok")
    except:
        print 111

只要關閉連接就會報錯,不知道那里出了問題
還有就是,無需再app中注冊dwebsocket

詳細代碼請參考:
https://github.com/huguodong/dj_dwebsocket


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM