onClose(): How to distinguish between unestablished connections and opened connections?
14 views
Skip to first unread message
Tomforge
unread,
Jun 3, 2018, 8:10:16 AM6/3/18
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Autobahn
I am writing a websocket server in Autobahn Python with the Twisted framework. Currently I am doing something like this:
classMyProtocol(WebSocketServerProtocol): def onOpen(self): # Do some initialization
def onClose(self, wasClean, code, reason): # Do some cleanup
The problem is, denied/unable to be established websocket connections (which don't trigger `onOpen()`) triggers `onClose()`. Is there an Autobahn/Twisted way for me to perform cleanup only for previously opened connections, ignoring unestablished connections? Can i determine this from the error code alone, or should i just set a `self.wasOpen = True` flag in my protocol's `onOpen()`?