我在设备上连接到Realm Object Server时遇到问题,但它可以在模拟器上运行。 它是返回错误:
Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server."
UserInfo={NSUnderlyingError=0x170255450 {Error
Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" UserInfo=
{_kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}},
NSErrorFailingURLStringKey=http://127.0.0.1:9080/auth,
NSErrorFailingURLKey=http://127.0.0.1:9080/auth, _kCFStreamErrorDomainKey=1,
_kCFStreamErrorCodeKey=61, NSLocalizedDescription=Could not connect to the
server.}): file
/Users/tungvu/Desktop/Swift3Xcode8/RealmTask/RealmTask/ViewController.swift,
line 57
这是我与Realm Object Server功能的连接:
SyncUser.logIn(with: .usernamePassword(username: username, password: password, register: false), server: URL(string : "http://127.0.0.1:9080")!) { (user, error) in
guard let user = user else {
fatalError(String(describing: error))
}
DispatchQueue.main.async {
// Open Realm
let configuration = Realm.Configuration(
syncConfiguration: SyncConfiguration(user: user, realmURL: URL(string: "realm://127.0.0.1:9080/~/realmtasks")!)
)