<div dir="ltr"><div>Hi all,</div><div><br></div><div>I have been using pylxd to interact LXD REST API. I create a container and then send</div><div>the /bin/bash cmd using the raw_interactive_execute function. <br></div><div>Concretely here is my function call</div><div><br></div><div>res = container.raw_interactive_execute(['/bin/bash', ], environment={"TERM":"xterm"})</div><div>I got back the websocket secret and the control. So far so good. I am opening a websocket to</div><div>interact with the container as follows:</div><div><br></div><div>websocket.enableTrace(False)<br>ws = websocket.WebSocketApp(uri,<br>                                    on_message=on_message,<br>                                    on_error=on_error,<br>                                    on_close=on_close,<br>                                    on_open=on_open)<br><br>    ws.run_forever(sslopt={"cert_reqs": ssl.CERT_NONE}, ping_interval=0, ping_timeout=0)<br>    ws.close()</div><div><br></div><div>Here is also the on_open</div><div><br></div><div>def on_open(ws):<br>       def run(*args):<br>          <br></div><div>               while True:<br>                                            cmd = get_user_input()<br>                      cmd += "\r"<br>                                         print("Sending CMD: ", cmd)<br>                                            cmd = bytearray(cmd, encoding='utf-8')<br>                      ws.send(cmd, opcode=2)<br>                                        time.sleep(1)<br><br>                             print("Closing connection...")<br>                            ws.close()<br>                                 print("thread terminating...")<br>               thread.start_new_thread(run, ())</div><div><br></div><div>I then open the control as follows <br></div><div><br></div><div>uri = 'some_uri_generated'<br>websocket.enableTrace(False)<br> ws = websocket.WebSocketApp(uri,<br>                                                              on_message=on_message,<br>                                                                on_error=on_error,<br>                                                            on_close=on_close)<br><br>  ws.on_open = on_open<br>  ws.run_forever(sslopt={"cert_reqs": ssl.CERT_NONE}, ping_interval=0, ping_timeout=0)<br>        ws.close()</div><div><br></div><div><br></div></div>