As mentioned in chats, I am trying to save the messages to a file.
def save_message(msg):
with open(f"{uuid.uuid4()}.json", 'w+') as fh:
fh.write(json.dumps(msg))
hub_connection.on_open(lambda: print("connection opened and handshake received ready to send messages"))
hub_connection.on_close(lambda: print("connection closed"))
hub_connection.on("ReceiveMessage", self.save_message())
Please advice how to fix it, Also if I need to close the socket connection only after receiving a particular message(for eg close socket if I received word'completed' in it). How to do that.
As mentioned in chats, I am trying to save the messages to a file. def save_message(msg): with open(f"{uuid.uuid4()}.json", 'w+') as fh: fh.write(json.dumps(msg))
hub_connection = HubConnectionBuilder() \ .with_url(SERVER_URL(design_id, connection_token), options={"verify_ssl": False, "skip_negotiation": False, "headers": { "Cookie": "uac.authorization={}".format(token) } }) \ .configure_logging(logging.DEBUG, socket_trace=True, handler=handler) \ .with_automatic_reconnect({ "type": "interval", "keep_alive_interval": 10, "intervals": [1, 3, 5, 6, 7, 87, 3] }).build()
Please advice how to fix it, Also if I need to close the socket connection only after receiving a particular message(for eg close socket if I received word'completed' in it). How to do that.