user261922 user261922 - 1 year ago 95
Swift Question

struggling with NMSSH in swift; errors -2, -9, -18,

I am trying to implement something using the

framework in swift.

To not have my UI freeze while collecting data from the servers I put everything inside a

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0))

And I sometimes (about 50% probability) randomly get one of these errors. I am not sure what causes them or how to prevent them. The appear seemingly randomly, but in chains, one it goes wrong it will keep going wrong for a while, and when it finally works it will work a few times in a row.

Socket connection to on port 22 failed with reason -2, trying next address...

Error Domain=libssh2 Code=-18 "Authentication failed (keyboard-interactive)" UserInfo={NSLocalizedDescription=Authentication failed (keyboard-interactive)}

Error Domain=libssh2 Code=-9 "Waiting for password response" UserInfo={NSLocalizedDescription=Waiting for password response}

but most frequently

Error Domain=libssh2 Code=-9 "Would block requesting userauth list" UserInfo={NSLocalizedDescription=Would block requesting userauth list}


Error Domain=libssh2 Code=-9 "Would block" UserInfo={NSLocalizedDescription=Would block}

EDIT: I pasted my whole code here, but it is kinda messy.
The function is supposed to be called once and then check a bunch of servers for their availability.

returns an array of dictionaries, each looking like
["alias": "iMac", "ip":" mac.local", "port":"22", "username": "root", "password": "123"]


Try using NSOperationQueue, it is higher level and might be able to handle that better