Browser Streaming Robot and Websocket[SOLVED]



I am definitly learning as fast as I can, Python and tornado server. In your example project, browser streaming robot (which I can run perfectly and have actually modified some of the code myself) how can I configure “” so it can write_message back to the connected user.

I grabbed this from the tornado docs but obviously we dont have a reference to “self.ws_connection”. how can i configure your script so I can return a message? I would like to us eit for the ultrasonic sensor and return distance (I have the python code all written to GET the value, just need to return it via the web socket connection)

Thanks for any guidance!!

def write_message(self, message, binary=False):
    """Sends the given message to the client of this Web Socket.        
    if self.ws_connection is None:
        raise WebSocketClosedError()
    if isinstance(message, dict):
        message = tornado.escape.json_encode(message)
    return self.ws_connection.write_message(message, binary=binary)


I believe I figured it out. I noticed the ConnectionHandler was using (sockjs.tornado.SockJSConnection) and not (tornado.websocket.WebSocketHandler) so you need to use self.send() instead of write_message()

def send_message(self, message):

    return self.send(json.dumps({
        'data_type': "json",
        'data': message,


Hi @paul.reisinger,

Sorry for the delay. Its good to hear that you found out and thanks for sharing it in the forums. Get back to us if you need any assistance further.



This topic was automatically closed after 24 hours. New replies are no longer allowed.