-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
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
Metadata
Metadata
Assignees
Labels
No labels