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

unable to handle ssh network errors #764

Open
GalGof opened this issue May 14, 2024 · 3 comments
Open

unable to handle ssh network errors #764

GalGof opened this issue May 14, 2024 · 3 comments

Comments

@GalGof
Copy link

GalGof commented May 14, 2024

example:

// process.on('uncaughtException', function (err) {
//   console.error("uncaughtException:", err.stack);
// });

const Docker = require('dockerode');


try {
  let docker = new Docker({
    host: "127.0.0.1",
    protocol: "ssh",
    username: "root",
    sshOptions: {
      host: "127.0.0.1",
      port: 4556,
    }
  });
  console.log('created')
  docker.ping()
    .then(()=>{console.log("ping ok")})
    .catch(()=>{console.error("ping failed")});
} catch (error) {
  console.error("catch", error);  
}

setInterval(()=>console.log(+new Date()), 60000)

expected:
"ping failed" in console

actual:
node process crushed

node .\test.cjs
created
****\node_modules\docker-modem\lib\ssh.js:40
throw err;
^

Error: connect ECONNREFUSED 127.0.0.1:22
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1605:16) {
errno: -4078,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 22,
level: 'client-socket'
}

is there no way to handle network connection errors to docker engine?
simple example above - without node's uncaughtException handler - process crashes.
but node's handler doesnt help as there is no way to tell where error occured.
request to dockerode simly hangs without beeing rejected.

"node_modules/dockerode": {
  "version": "4.0.2",
"node_modules/docker-modem": {
  "version": "5.0.3",
@SquirrelCorporation
Copy link

Hi!
I also encountered this error, the (temporary) solution is to use a custom agent in the modem, waiting for this PR (https://github.com/apocas/docker-modem/pull/163/files) to be merged

@GalGof
Copy link
Author

GalGof commented May 21, 2024

in simple case seems like working with it, but i wonder what's wrong with it if it's not merged for a year...

@gaberudy
Copy link

I've created apocas/docker-modem#179 that fixes this issue and replaces the PR above with one that is built on the master branch and handles all the current error paths.

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