在 swift 中与 NMSSH 作斗争;错误 -2、-9、-18、
struggling with NMSSH in swift; errors -2, -9, -18,
我正在尝试使用 swift 中的 NMSSH
框架来实现一些东西。
为了不让我的 UI 在从服务器收集数据时冻结,我将所有内容都放在
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0))
而且我有时(大约 50% 的概率)随机得到这些错误之一。我不确定是什么原因导致它们或如何预防它们。看似随机出现,其实是环环相扣的,一次出错会一直出错一段时间,等到好起来的时候又会连续好几次。
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}
但最常见
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}
编辑:我粘贴了我的整个代码 here,但它有点乱。
该函数应该被调用一次,然后检查一堆服务器的可用性。
getServers()
returns 字典数组,每个看起来像 ["alias": "iMac", "ip":" mac.local", "port":"22", "username": "root", "password": "123"]
尝试使用 NSOperationQueue
,它的级别更高,可能能够更好地处理
我正在尝试使用 swift 中的 NMSSH
框架来实现一些东西。
为了不让我的 UI 在从服务器收集数据时冻结,我将所有内容都放在
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0))
而且我有时(大约 50% 的概率)随机得到这些错误之一。我不确定是什么原因导致它们或如何预防它们。看似随机出现,其实是环环相扣的,一次出错会一直出错一段时间,等到好起来的时候又会连续好几次。
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}
但最常见
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}
编辑:我粘贴了我的整个代码 here,但它有点乱。 该函数应该被调用一次,然后检查一堆服务器的可用性。
getServers()
returns 字典数组,每个看起来像 ["alias": "iMac", "ip":" mac.local", "port":"22", "username": "root", "password": "123"]
尝试使用 NSOperationQueue
,它的级别更高,可能能够更好地处理