struggling with NMSSH in swift; errors -2, -9, -18,
<p>I am trying to implement something using the <code>NMSSH</code> framework in swift.</p>

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

<pre><code>dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0))
</code></pre>

<p>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.</p>

<pre><code>Socket connection to 192.168.178.27 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}
</code></pre>

<p>but most frequently</p>

<pre><code>Error Domain=libssh2 Code=-9 "Would block requesting userauth list" UserInfo={NSLocalizedDescription=Would block requesting userauth list}
</code></pre>

<p>and</p>

<pre><code>Error Domain=libssh2 Code=-9 "Would block" UserInfo={NSLocalizedDescription=Would block}
</code></pre>

<p>EDIT: I pasted my whole code <a href="http://pastebin.com/wbi8MzPL" rel="nofollow">here</a>, but it is kinda messy.
The function is supposed to be called once and then check a bunch of servers for their availability.</p>

<p><code>getServers()</code> returns an array of dictionaries, each looking like <code>["alias": "iMac", "ip":" mac.local", "port":"22", "username": "root", "password": "123"]</code></p>