What language are you doing that from?
When interactive, a single bi-directional websocket is used for data, alongside the control websocket to send things like signals and window resize events.
When non-interactive, you instead get 3 websockets for data, one for each of stdin, stdout and stderr as well as the control socket.
As you want interactive, you’d to connect to the single data websocket, write to send to stdin, read to get stdout/stderr. If you need to differentiate between stdout and stderr, then you want non-interactive instead.
As for knowing when done, you want a thread/goroutine to wait for the background operation.
In Go, calling
ExecContainer will return an
op which has a
Wait() function for this purpose.
So you want a thread/goroutine to handle input/output and one to wait for the execution to end or connection to fail and handle that.
We have a number of examples for this if you’re writing in Go, for other languages, examples are a bit more sparse. I believe pylxd has some support for this in python though.