V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 2016-03-14 11:20:33 +08:00 · 2970 次点击
    这是一个创建于 2966 天前的主题,其中的信息可能已经有所发展或是发生改变。
    看文档里写的 ,当 websocket 被关闭时触发该事件 ,当我关闭页面时,调用 ws_connection 显示 websocket 已经关闭连接了,但是并没有触发 onclose 事件,

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

    请问,怎样才能触发 onclose 这个事件呢,大家有对 websocket 熟悉的么,多谢指教啊~~
    2 条回复    2016-03-15 17:55:14 +08:00
    zhfsxtx
        1
    zhfsxtx  
       2016-03-14 11:42:52 +08:00   ❤️ 1
    客户端需要给服务端发送一个 CloseWebSocketFrame , 服务端收到 之后才会 close socket
    wdg8106
        2
    wdg8106  
    OP
       2016-03-15 17:55:14 +08:00
    @zhfsxtx 多谢,问题解决了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2910 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 08:53 · PVG 16:53 · LAX 01:53 · JFK 04:53
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.