セットアップ:私は初めてのテストレルムiOSの11とXcode 9AWSのRealm Object Server(ROS):有効なWebsocketリクエストを作成する方法は?
を使用してFirebaseの代替として検討しています
。 Tokyo公開AMIに基づいてAWS ECでテストサーバを稼働させました。 Dashboardが動作し、Swiftコードのユーザーを追加すると、領域が作成されます。
問題:
はどちらか なって、書き込むことができません "接続[1]:SSLハンドシェイクが失敗しました:入力の早すぎる終わりを" I "は、レルム://" を使用する場合、または「接続を[1]:同期サーバのURLとして「realm://」を使用する場合は、「書き込みに失敗しました:入力の終了」を選択します。 SSLエラーを検出しようとしましたが、一致するものは見つかりませんでした。
RealmのWebサイトのチュートリアルが作成されたときから、コードの多くが変更されたので即座に修正する必要がありました。おそらく本当に間違いがあるかもしれません。
ここに私のコードです。 「realsms://」
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 = "[email protected]"
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)")
}
}
}
}
ここでエラーログだと、これが無限ループに入る:
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
そして、私は「王国://」を使用する場合、これはログです、に入りますループも同様に:
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)