推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
wdg8106
V2EX  ›  Python

tornado , websokcet 什么时候会调用 onclose 函数呢?

  •  
  •   wdg8106 · Mar 14, 2016 · 3975 views
    This topic created in 3857 days ago, the information mentioned may be changed or developed.
    看文档里写的 ,当 websocket 被关闭时触发该事件 ,当我关闭页面时,调用 ws_connection 显示 websocket 已经关闭连接了,但是并没有触发 onclose 事件,

    前端用 js 调用 ws.close() 函数 主动关闭 websocket 也没有触发这个事件。

    请问,怎样才能触发 onclose 这个事件呢,大家有对 websocket 熟悉的么,多谢指教啊~~
    2 replies  •  2016-03-15 17:55:14 +08:00
    zhfsxtx
        1
    zhfsxtx  
       Mar 14, 2016   ❤️ 1
    客户端需要给服务端发送一个 CloseWebSocketFrame , 服务端收到 之后才会 close socket
    wdg8106
        2
    wdg8106  
    OP
       Mar 15, 2016
    @zhfsxtx 多谢,问题解决了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2279 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 05:28 · PVG 13:28 · LAX 22:28 · JFK 01:28
    ♥ Do have faith in what you're doing.