Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Websocket error on HTTP Operation #20

Open
yanover opened this issue Dec 31, 2020 · 1 comment
Open

Websocket error on HTTP Operation #20

yanover opened this issue Dec 31, 2020 · 1 comment

Comments

@yanover
Copy link

yanover commented Dec 31, 2020

Hey guys !

I’m building a web interface to manage my LXD containers. I use the lxd-node library to make my requests.

I can get my hosts and containers, stop, start or restart them but when it comes to sending commands, it doesn’t work.

I know that the node-lxd project is no longer maintained and I hesitate to create my requests directly by querying the LXD API but I would still like your feedback :

This is my function to send a command, I took the same example as in the official documentation, I just retrieve my container with an external function (which is working) :

public async execute(
    host: HostDto,
    container: ContainerDto,
    command: CmdDto,
  ) {
    let target = await this.getContainer(host, container);

    target.exec(['sleep', '5'], (err, process) => {
      if (err != null) {
        console.error(err);
        return;
      }

      process.on('close', () => {
        console.log('process closed');
      });
    });
  }

Unfortunately, my server is saying :

Error: unexpected server response (400)
    at ClientRequest.response (D:\Programation\Nasticot\NAS-SERVER\project\node_modules\ws-unix\lib\WebSocket.js:704:15)
And this part of the Websocket library is the following :
if (!self.emit('unexpected-response', req, res)) {
    error = new Error('unexpected server response (' + res.statusCode + ')');
    req.abort();
    self.emit('error', error);
 }

I probably miss something … If anyone has an idea, it would be very appreciated !

Thank you

@Thanayaby
Copy link

Thank you very much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants