External websocket client

I want to make ERPNext communicate with an external device through websocket. I can connect to port 9000 with a python script but get immediately disconnected. What could be the right way to listen and respond to websocket messages from another system?

Bumping this. I need to drive an external tool from Frappe and I am hoping to either integrate with the existing socketio server or host another with Hooks. It’d be nice to use the pre-existing socketio server, but I am unclear on how to authenticate.