[lxc-users] Interacting with api websockets

Caleb Everett caleb at calebeverett.io
Tue May 3 23:36:12 UTC 2016

I got this going. Here is a gist if any one else happens upon this.


On Mon, May 2, 2016 at 11:27 AM, Caleb Everett <caleb at calebeverett.io>

> I've been trying to get the websockets for the operations endpoint
> working. I was trying to submit a command to the exec endpoint
> <https://github.com/lxc/lxd/blob/master/doc/rest-api.md#10containersnameexec>
> and then establish a websocket connection to interact with the command. I'm
> probably missing something basic, but if anyone were willing to send me a
> couple of links or some ideas about how to figure it out, that would be
> great.
> My test case was to submit a command of "/bin/bash" with the
> "interactive": true and "wait-for-websocket": true. When I hit the
> operations
> <https://github.com/lxc/lxd/blob/master/doc/rest-api.md#10operations>
> endpoint I can see that the process running. When I open up a secure
> websocket connection at this
> <https://github.com/lxc/lxd/blob/master/doc/rest-api.md#10operationsuuidwebsocket>
> endpoint using this
> <https://chrome.google.com/webstore/detail/simple-websocket-client/pfdhoblngboilpfeibdedpjgfnlcodoo> Chrome
> extension, the connection opens and I can send commands through, but
> nothing ever comes back.
> I also tried submitting a non-interactive command and opening up separate
> connections for each of the 0, 1 and 2 secrets and then sending commands
> through on the 0 connection to see if anything would come back on either
> the 1 or 2 connection, but nothing came back.
> I also tried establishing the connections with a snippet in the Chrome
> console using the native browser Websocket
> <https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API> and
> also via nodejs with the ws <https://github.com/websockets/ws> package,
> but essentially got to the same place, which is opened connection, but not
> able to get any response back.
> I found this project <https://github.com/dobin/lxd-webgui> which connects
> a javascript terminal to the streams, but I'd like to figure out how to
> interact with the endpoints programatically.
> What else do I need to do to be able to exchange information with the
> websocket endpoints?  Also, what does the secret for "control" do?
> Lastly, is this this right forum for these kinds of questions? If they are
> too basic and I should be availing myself of alternative resources, I don't
> want to be out of school.
> Thank you,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20160503/bc0dd725/attachment.html>

More information about the lxc-users mailing list