网络连接丢失错误

Network connection was lost error

我正在尝试从使用 swift 在 macOS

上开发的应用程序连接到领域对象服务器

当我尝试连接时,出现此错误 "Network connection was lost",但我可以从浏览器打开领域服务器而没有问题。顺便说一句,这个问题最近发生了,几周前它工作正常

let credentials = SyncCredentials.usernamePassword(username: username, password: password)

SyncUser.logIn(with: credentials, server: serverurl) {
            user, error in

            if let u = user {
                onCompletion(syncUser: u, error: nil)
            } else if let error = error {
                onCompletion(syncUser: nil, error: error)
            } else {
                onCompletion(syncUser: nil, error: nil)
            }
        }

这里,用户总是nil,错误描述是Network connection was lost

本地服务器和托管在 digitalocean 上的服务器都会发生这种情况

服务器版本 1.8.3

xcode 控制台日志

2018-01-15 12:46:07.077741+0300 Oncobase[8138:9497304] ApplePersistence=NO 2018-01-15 12:46:07.207859+0300 Oncobase[8138:9497813] dnssd_clientstub ConnectToServer: connect()-> No of tries: 1 2018-01-15 12:46:08.218889+0300 Oncobase[8138:9497813] dnssd_clientstub ConnectToServer: connect()-> No of tries: 2 2018-01-15 12:46:09.228932+0300 Oncobase[8138:9497813] dnssd_clientstub ConnectToServer: connect()-> No of tries: 3 2018-01-15 12:46:10.239595+0300 Oncobase[8138:9497813] dnssd_clientstub ConnectToServer: connect() failed path:/var/run/mDNSResponder Socket:16 Err:-1 Errno:1 Operation not permitted 2018-01-15 12:46:10.239850+0300 Oncobase[8138:9497813] [] nw_resolver_create_dns_service_locked DNSServiceCreateDelegateConnection failed: ServiceNotRunning(-65563) 2018-01-15 12:46:10.240322+0300 Oncobase[8138:9497813] TIC TCP Conn Failed [1:0x600000163300]: 10:-72000 Err(-65563) 2018-01-15 12:46:10.257327+0300 Oncobase[8138:9497796] Task .<1> HTTP load failed (error code: -1003 [10:-72000]) 2018-01-15 12:46:10.257548+0300 Oncobase[8138:9497796] Task .<1> finished with error - code: -1003 2018-01-15 12:46:23.852072+0300 Oncobase[8138:9497838] [] nw_socket_connect connectx failed (fd 16, 127.0.0.1:9080 stream, pid: 8138, sanitized url: http://127.0.0.1:9080/auth): [1] Operation not permitted 2018-01-15 12:46:23.852142+0300 Oncobase[8138:9497838] [] nw_socket_get_input_frames recvmsg(fd 16, 1024 bytes): [57] Socket is not connected 2018-01-15 12:46:23.852284+0300 Oncobase[8138:9497838] TIC TCP Conn Failed [2:0x600000169b40]: 1:57 Err(57) 2018-01-15 12:46:23.852618+0300 Oncobase[8138:9497838] Task <91597B31-6AB4-41BB-A5A6-C32525BC8A67>.<2> HTTP load failed (error code: -1005 [1:57]) 2018-01-15 12:46:23.853839+0300 Oncobase[8138:9497798] Task <91597B31-6AB4-41BB-A5A6-C32525BC8A67>.<2> finished with error - code: -1005

编辑 1:我刚刚启用了沙盒,以便能够将应用程序上传到苹果应用程序商店。这可能是问题所在吗?任何解决方法?

沙盒似乎才是真正的问题

我必须启用带沙盒的传入连接和传出连接才能正常工作

你必须关闭 "App Sandbox"。

前往:xcode 项目 -> 功能 -> App SandBoxScreenShot