node-lxd icon indicating copy to clipboard operation
node-lxd copied to clipboard

Parse error on container.run()

Open woubuc opened this issue 6 years ago • 11 comments

When I try to run a command on my container, I get the following error:

Error: Parse Error
    at Socket.socketOnData (_http_client.js:444:20)
    at Socket.emit (events.js:127:13)
    at addChunk (_stream_readable.js:269:12)
    at readableAddChunk (_stream_readable.js:256:11)
    at Socket.Readable.push (_stream_readable.js:213:10)
    at TCP.onread (net.js:598:20)

My code:

container.run(['ls -al'], function(err, stdout, stderr) {
    if (err) return console.error(err);
    console.log('out:', stdout);
    console.log('err:', stderr);
});

woubuc avatar Apr 22 '18 21:04 woubuc

Looking into it now, but can't seem to replicate. Can you provide any more information on your setup?

alandoherty avatar May 11 '18 12:05 alandoherty

We looked into the issue, I don't recall the specifics but it had something to do with the library not using secure websockets on windows. We patched it for our use case, see the added commits in https://github.com/epicteddy/node-lxd

woubuc avatar May 11 '18 12:05 woubuc

Having this same exact issue attempting to do both a container.exec and a container.run. After I incorporated @woubuc's changes I get this error now.

{ Error: unable to verify the first certificate
    at TLSSocket.<anonymous> (_tls_wrap.js:1103:38)
    at emitNone (events.js:106:13)
    at TLSSocket.emit (events.js:208:7)
    at TLSSocket._finishInit (_tls_wrap.js:637:8)
    at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:467:38) code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE' }

anthonyloukinas avatar May 18 '18 20:05 anthonyloukinas

I am getting a similar error when trying to use container.run, but it also shows a HPE_INVALID_CONSTANT code:

Error: Parse Error
  at Socket.socketOnData (_http_client.js:440:20)
  at emitOne (events.js:116:13)
  at Socket.emit (events.js:211:7)
  at addChunk (_stream_readable.js:263:12)
  at readableAddChunk (_stream_readable.js:250:11)
  at Socket.Readable.push (_stream_readable.js:208:10)
  at TCP.onread (net.js:597:20) bytesParsed: 0, code: 'HPE_INVALID_CONSTANT' } } reason: { Error: Parse Error
  at Socket.socketOnData (_http_client.js:440:20)
  at emitOne (events.js:116:13)
  at Socket.emit (events.js:211:7)
  at addChunk (_stream_readable.js:263:12)
  at readableAddChunk (_stream_readable.js:250:11)
  at Socket.Readable.push (_stream_readable.js:208:10)
  at TCP.onread (net.js:597:20) bytesParsed: 0, code: 'HPE_INVALID_CONSTANT'

lpgera avatar Jul 19 '18 10:07 lpgera

@lpgera will look into it but it looks like that may be a transient error on your end, are you sure the target endpoint is correct? Also may be a incorrectly setup proxy inbetween

alandoherty avatar Jul 19 '18 10:07 alandoherty

We had our own working implementation before, I am just trying to use this package because its control socket handling is better. So I don't think its a proxy or endpoint related problem. I'll try to narrow it down whether its a problem with the ws dependency.

lpgera avatar Jul 19 '18 10:07 lpgera

It was the same problem that has been patched in https://github.com/epicteddy/node-lxd. The certificate was not used when it was connecting to the websockets.

lpgera avatar Jul 20 '18 08:07 lpgera

same issue, i can create containers, delete them, start them, but can not run or execute anything in them. using https://github.com/epicteddy/node-lxd did not change a thing for me

Error: Parse Error at Socket.socketOnData (_http_client.js:440:20) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at addChunk (_stream_readable.js:263:12) at readableAddChunk (_stream_readable.js:250:11) at Socket.Readable.push (_stream_readable.js:208:10) at TCP.onread (net.js:607:20) bytesParsed: 0, code: 'HPE_INVALID_CONSTANT' }

tomevoll avatar Jul 28 '18 08:07 tomevoll

Is there any solution that works for this? Anyone know of a different lib i could use to exec ?

tomevoll avatar Jul 28 '18 18:07 tomevoll

any solution?

3xtr3m3d avatar Feb 01 '19 06:02 3xtr3m3d

mmm, i solved problem for my case. added a pull request if anyone want (new to github and don't really know how pull requests and forks work).

3xtr3m3d avatar Feb 01 '19 11:02 3xtr3m3d