简体   繁体   中英

tornado websocket closing on server-side

I have a connection to websocket handler in my tornado app, and when i try to close it on server-side, i get unexpected event code which is not equal to one that i've specified in closing parameters

Handler's method code:

def on_message(self, message):
    # do some stuff
    self.close(code=200)

On client-side i expect onclose_event.code will be 200 but it appears to be 1006 , is there a correct way to close websocket connection 'clearly' with specified code in tornado?

Tornado version i use is 4.1

Can you try Tornado 4.2? Handling of close codes changed in that version, although I'm not sure if it will fix this problem or not.

From the 4.2 release notes : "When the other side closes a connection, we now echo the received close code back instead of sending an empty close frame."

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM