设置:
我使用的是iOS 11和Xcode 9
第一次测试领域,并考虑作为Firebase的替代品。基于提供的东京公共AMI,在AWS EC中安装并运行了测试服务器。仪表板工作,从Swift代码工作中添加用户,甚至创建领域。
问题:
无法写入,在使用“领域://”时获取“连接[1]:SSL握手失败:输入过早结束”,或在将“领域://”用作同步服务器URL时获取“连接[1]:写入失败:输入结束”。尝试通过谷歌搜索SSL错误,但未找到任何匹配项。
从Realm网站上的教程制作开始,很多代码都发生了变化,所以我不得不临时修改,可能是有一些非常明显的错误,或者可能是我的服务器配置?
这是我的代码。
var realm: Realm?
if let serverURL = URL(string: "http://13.112.252.130:9080"){
let usernameCredentials = SyncCredentials.usernamePassword(username: "raul", password: "abc123", register: false)
SyncUser.logIn(with: usernameCredentials,
server: serverURL) { user, error in
if let user = user {
print("User \(user) is admin: \(user.isAdmin)")
if let syncServerURL = URL(string: "realms://13.112.252.130:9080/~/addressBook") {
let config = Realm.Configuration(syncConfiguration: SyncConfiguration(user: user, realmURL: syncServerURL))
realm = try? Realm(configuration: config)
print("Successfully connected to realm!")
let contact = Contact()
contact.name = "John Doe"
contact.phone = "123456789"
contact.email = "john.doe@gmail.com"
if let realm = realm {
self.contactResults = realm.objects(Contact.self).sorted(byKeyPath: "name", ascending: true)
try? realm.write {
realm.add(contact)
print("wrote to realm!")
}
}
} else if let error = error {
print("Error: \(error.localizedDescription)")
}
}
}
}
这是带有“realms://”的错误日志,它进入了一个无限循环:
2017-09-02 07:37:18.223475+0700 RealmAdressbook[7253:3703339] refreshPreferences: HangTracerEnabled: 1
2017-09-02 07:37:18.223532+0700 RealmAdressbook[7253:3703339] refreshPreferences: HangTracerDuration: 500
2017-09-02 07:37:18.223551+0700 RealmAdressbook[7253:3703339] refreshPreferences: ActivationLoggingEnabled: 0 ActivationLoggingTaskedOffByDA:0
User is admin: false
Successfully connected to realm!
2017-09-02 07:37:19.319628+0700 RealmAdressbook[7253:3703453] Sync: Opening Realm file: /var/mobile/Containers/Data/Application/2A52579D-4863-4FC3-88DA-31F2EC2549E5/Documents/realm-object-server/64e042b0-d753-4ebf-b5a4-de8f8f56142f/realms%3A%2F%2F13.112.252.130%3A9080%2F%7E%2FaddressBook
2017-09-02 07:37:19.320459+0700 RealmAdressbook[7253:3703453] Sync: Connection[1]: Session[1]: Starting session for '/var/mobile/Containers/Data/Application/2A52579D-4863-4FC3-88DA-31F2EC2549E5/Documents/realm-object-server/64e042b0-d753-4ebf-b5a4-de8f8f56142f/realms%3A%2F%2F13.112.252.130%3A9080%2F%7E%2FaddressBook'
2017-09-02 07:37:19.320591+0700 RealmAdressbook[7253:3703453] Sync: Connection[1]: Resolving '13.112.252.130:9080'
2017-09-02 07:37:19.322722+0700 RealmAdressbook[7253:3703453] Sync: Connection[1]: Connecting to endpoint '13.112.252.130:9080' (1/1)
2017-09-02 07:37:19.458271+0700 RealmAdressbook[7253:3703453] Sync: Connection[1]: Connected to endpoint '13.112.252.130:9080' (from xxxxxxxxxxxxx)
2017-09-02 07:37:19.597335+0700 RealmAdressbook[7253:3703453] Sync: Connection[1]: SSL handshake failed: Premature end of input
2017-09-02 07:37:19.597609+0700 RealmAdressbook[7253:3703453] Sync: Connection[1]: Connection closed due to error
这是我使用“realm://”时的日志,也会进入循环:
2017-09-02 07:41:00.362705+0700 RealmAdressbook[7263:3705293] refreshPreferences: HangTracerEnabled: 1
2017-09-02 07:41:00.362762+0700 RealmAdressbook[7263:3705293] refreshPreferences: HangTracerDuration: 500
2017-09-02 07:41:00.362782+0700 RealmAdressbook[7263:3705293] refreshPreferences: ActivationLoggingEnabled: 0 ActivationLoggingTaskedOffByDA:0
User is admin: false
Successfully connected to realm!
wrote to realm!
2017-09-02 07:41:01.524168+0700 RealmAdressbook[7263:3705496] Sync: Opening Realm file: /var/mobile/Containers/Data/Application/36B5D609-1E8B-48FD-B20A-F5DF4EB21384/Documents/realm-object-server/64e042b0-d753-4ebf-b5a4-de8f8f56142f/realm%3A%2F%2F13.112.252.130%3A9080%2F%7E%2FaddressBook
2017-09-02 07:41:01.525491+0700 RealmAdressbook[7263:3705496] Sync: Connection[1]: Session[1]: Starting session for '/var/mobile/Containers/Data/Application/36B5D609-1E8B-48FD-B20A-F5DF4EB21384/Documents/realm-object-server/64e042b0-d753-4ebf-b5a4-de8f8f56142f/realm%3A%2F%2F13.112.252.130%3A9080%2F%7E%2FaddressBook'
2017-09-02 07:41:01.526011+0700 RealmAdressbook[7263:3705496] Sync: Connection[1]: Resolving '13.112.252.130:9080'
2017-09-02 07:41:01.527816+0700 RealmAdressbook[7263:3705496] Sync: Connection[1]: Connecting to endpoint '13.112.252.130:9080' (1/1)
2017-09-02 07:41:01.663245+0700 RealmAdressbook[7263:3705496] Sync: Connection[1]: Connected to endpoint '13.112.252.130:9080' (from '192.168.1.4:59862')
2017-09-02 07:41:01.819181+0700 RealmAdressbook[7263:3705496] Sync: Connection[1]: Writing failed: End of input
2017-09-02 07:41:01.819320+0700 RealmAdressbook[7263:3705496] Sync: Connection[1]: Connection closed due to
error
来自服务器的日志我的请求头似乎有问题,如何修复?
proxy: [syncProxy] internal error: Error: socket hang up at createHangUpError (httpclient.js:253:15) at Socket.socketOnEnd (httpclient.js:345:23) at emitNone (events.js:91:20) at Socket.emit (events.js:185:7) at endReadableNT (streamreadable.js:974:12) at combinedTickCallback (internal/process/nexttick.js:80:11) at process.tickCallback (internal/process/nexttick.js:104:9).
1:51:33 AMinfo
sync: HTTP Connection[714]: Connection closed due to error
1:51:33 AMerror
sync: HTTP Connection[714]: Check the proxy configuration and make sure that the HTTP request is a valid Websocket request. The header values are case sensitive
1:51:33 AMerror
sync: HTTP Connection[714]: The HTTP request with the error is: GET /realm-object-server HTTP/1.1
connection: Upgrade
host: 13.112.252.130
sec-websocket-key: 7FDPgyFxq/GT1tKfIMJNcg==
sec-websocket-protocol: io.realm.sync.19
sec-websocket-version: 13
upgrade: websocket
x-realm-access-token: eyJhY2Nlc3MiOlsiZG93bmxvYWQiLCJ1cGxvYWQiLCJtYW5hZ2UiXSwiYXBwX2lkIjoiY29tLmJhbWJhbWxhYnMuUmVhbG1BZHJlc3Nib29rIiwiZXhwaXJlcyI6MTUwNDM3ODg4NiwiaWQiOiJlMjI0YTM5NmU4YTI0OWU1ODlhNWQ4OWM0ODczOTMzOCIsImlkZW50aXR5IjoiNjE1ZWUxMjU0MDA4ZDA5MWJiYTc1MjU4YTAyZWViZjYiLCJwYXRoIjoiLzYxNWVlMTI1NDAwOGQwOTFiYmE3NTI1OGEwMmVlYmY2L215UmVhbG0ifQ==:hyX8GtVHMIBho3Zw6pZfp9Gnl6O0C0Rl73V0EdX/a4ZWXMxcySFZmWbs0CxmjnpZUDNnFDK3PpXspN1YnGu2c5ByuRIpgpT7hkzwAil2EQzFeKFycYXwTbsp3a6X9npHETjxUfe9QWIIA5drz3VRPUI+0Tj+qspjbyPBcMhL6ZH3A8ubZHOIpjJpxRWGZbghdznf0g71Ta0SDyCYT4GB+fHuddzUH7RZgLkzBfoyIdJyfGccwVi1Qe/c0GTPzkH12TSyzHSwx9PnGadl1vBRuPci6fs+TE03rx6Gy7v73I37JpVVsiPm1omMG7FBdi60iQYQvItiycnle/rvb6+u3w==
x-realm-path: /615ee1254008d091bba75258a02eebf6/myRealm
1:51:33 AMerror
sync: HTTP Connection[714]: There must be a header of the form 'Sec-WebSocket-Protocol: io.realm.protocol'
1:51:33 AMinfo
sync: HTTP Connection[714]: Received: Sync HTTP request(protocol_version=-1)
SSL情况和非SSL情况下的故障原因可能不同。
对于SSL情况,您确定要使用端口9080吗?通常领域使用9443。
对于非SSL的情况,问题是头显然已经被中间代理重写了。服务器接收到的请求与预期的不同。我们可以在Realm解决这个问题。您现在唯一能做的就是更改代理。谢谢你的报道。
编辑回答:对于非SSL情况,服务器无法识别头的原因是您使用的是旧版本的服务器。似乎您升级了客户端而没有升级服务器。尝试使用最新版本的服务器。
我有一个领域对象服务器,并试图与Android设备同步数据,如: 它与工作正常,但在低互联网连接的情况下(例如,为模拟器设置网络类型),我得到了一个错误(调用): 是否可以通过低Internet连接同步数据?
我使用Realm对象服务器运行在数字海洋的最低选项(5美元/月)在Ubuntu服务器上。我一直收到连接拒绝错误;我不知道错误是来自DO还是ROS。 我不是Ubuntu方面的专家;因此,我进入并清除了/var/log中的所有日志,并尝试重新连接。当有大量记录需要同步时,我不断收到以下错误(在iOS上,客户端): 在ubuntu端,清除所有日志后,当我尝试连接到服务器时,会再次创建一个日志,,以下是内
我让AWS使用这个AMI-80347097从Realm网站运行AMI服务的实例。所以我现在有了EC2实例,但我不知道下一步该做什么。对不起,我对这类事情一无所知。 AWS实例的服务器URL是什么?对象服务器的管理员访问令牌是否仍然相同?或者我必须在EC2实例中做一些特定的事情?TT. TT 编辑:好的,我让对象仪表板实际工作,我可以登录。非常感谢你在这方面帮助我。我的最后一步实际上是连接到对象服务
3.4 ABP领域层 - 领域服务 3.4.1 简介 领域服务(或者服务,在DDD模式中)是被用来执行领域操作或者业务规则的。Eric Evans 在他的DDD书中这样说过:一个好的Service应该有以下三个特征: 与领域概念相关的操作不是Entity或Value Object 的一个自然部分; 接口是根据领域模型的其它元素定义的; 操作是无状态的。 领域服务和Application Servi
问题内容: 我可以选择进行迁移,但是我希望删除defaultRealm()中的所有内容。我如何轻松做到这一点? 是.deleteObjects唯一的函数。 我尝试了以下代码: 方法一 方法2 两者都无法防止迁移异常。 问题答案: 用途:
问题内容: 我的服务器上托管了一个json文件。当我尝试向json文件发出Ajax“ GET”请求时,它失败。 请参阅Safari中的控制台,其中显示“无法加载资源”。 Firebug显示“ 200 OK”,但未显示响应。甚至Firebug也不会显示JSON标签。 我相信这是因为不允许使用AJAX进行跨域请求。 我想知道如何克服这个问题?另外,如果要在服务器上启用跨域请求,则认为需要创建文件或其他