我正在尝试使用 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()
返回一个字典数组,每个字典看起来像 ["alias": "iMac", "ip":"mac.local", "port":"22 ", "用户名": "root", "密码": "123"]
最佳答案
尝试使用NSOperationQueue
,它的级别更高,可能能够更好地处理
关于swift - 在 swift 中与 NMSSH 作斗争;错误-2、-9、-18、,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38084097/