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

Error on connection: "connect ECANCELED at TCPConnectWrap.afterConnect" #816

Closed
ck-jrd opened this issue Aug 6, 2019 · 2 comments
Closed

Comments

@ck-jrd
Copy link

ck-jrd commented Aug 6, 2019

I'm trying to build a small Electron app, and I'm running into an issue trying to connect to my host.

Code:

let Client = require('ssh2').Client, 
    conn
ipcMain.on('send-path', (event, arg) => {
    conn = new Client()
    conn.on('ready', () => {
        console.log('Client :: ready')
    }).connect({
        host: hostIP,
        port: 22,
        username: hostUser,
        password: hostPass
    })
})

Error that I'm getting:

Uncaught Exception:
Error: connect ECANCELED [hostIP:22]
    at TCPConnectWrap.afterConnect [as oncomplete]
(net.js:1061:14)

When I try adding conn.on('error', function(err){ console.log(error) }), the app just freezes and logs nothing to the console.

@ck-jrd ck-jrd closed this as completed Aug 13, 2019
@ck-jrd
Copy link
Author

ck-jrd commented Aug 13, 2019

My own dumb fault. The script that was triggering the SSH2 connection was, in essence, inadvertently quitting the app before the connection could even start, which was why that error was occurring, and also why it was beachballing.

@mscdex
Copy link
Owner

mscdex commented Aug 13, 2019

Ah yes, I've been bitten by that before with Electron.

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