gpt4 book ai didi

amazon-web-services - AWS 上的 Realm 对象服务器 (ROS) : how to make a valid Websocket request?

转载 作者:太空宇宙 更新时间:2023-11-03 13:14:56 31 4
gpt4 key购买 nike

设置:

我正在使用 iOS 11 和 Xcode 9

第一次测试 Realm 并考虑作为 Firebase 的替代品。根据提供的东京公共(public) AMI,在 AWS EC 中启动并运行测试服务器。仪表板有效,通过 Swift 代码添加用户有效,甚至创建了 Realm 。

问题:

不能写,getting either当我使用“realms://”时出现“Connection[1]: SSL handshake failed: Premature end of input”或当使用“realm://”作为同步服务器时出现“Connection[1]: Writing failed: End of input”网址。尝试用谷歌搜索 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)")
}
}
}
}

这是带有“realsms://”的错误日志,这会进入无限循环:

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

来自服务器的日志似乎是我的请求 header 有问题,如何解决?

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 吗?通常 Realm 使用 9443。

对于非 SSL 情况,问题是 header 显然已被中间代理重写。服务器收到的请求与预期的不同。我们可以在 Realm 解决这个问题。您现在唯一可以做的就是更改代理。感谢您报告此事。

编辑后的答案:对于非 SSL 情况,服务器无法识别 header 的原因是您使用的是旧版本的服务器。看来你只升级了客户端,没有升级服务器。尝试使用最新版本的服务器。

关于amazon-web-services - AWS 上的 Realm 对象服务器 (ROS) : how to make a valid Websocket request?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46193622/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com