我已经完成了 Realm 移动平台教程(链接)。您创建了一个 Swift 任务应用程序。
我能够让应用程序和服务器在我的本地 Mac 上正常工作。我能够向表格视图添加任务。
然后我在 DigitalOcean 上创建了一个 Ubuntu 16.04 droplet。我设法让服务器运行并能够查看 Realm 仪表板。
问题是,当我使用新的服务器 IP 地址(ubuntu 实例)运行应用程序时,我看到“添加任务”弹出,但没有任务被添加到应用程序的表视图中。
以下代码将任务添加到数据库:
try! items.realm?.write {
items.insert(Task(value: ["text": text]), at: items.filter("completed = false").count)
}
当我在本地机器上运行代码时,它会插入值,但是insert
当我使用远程服务器时,该行永远不会被命中。
这是我将 Realm 配置设置为新 url 的地方:
let configuration = Realm.Configuration(
syncConfiguration: (user, URL(string: "realm://128.199.119.xxx:9080/~/realmtasks")!)
)
将 Realmconfiguration.yml
文件部署到远程服务器时是否必须更新它?如果是,是否有人有configuration.yml
示例或需要做些什么来设置文件?
在教程视频中提到 info.plist 需要更新。对于访问已部署服务器的应用程序或应用商店上的应用程序,info.plist 的以下版本是否相同?
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
这是结果cat /var/log/realm-object-server.log
:
2016-10-29T03:09:06.501Z - info: sync-server: Connection[5]: Connection from 127.0.0.1:58822
2016-10-29T03:09:06.631Z - info: sync-server: Connection[5]: Received: CLIENT(protocol_version=15, client_info_size=2, client_info='{}')
2016-10-29T03:09:06.788Z - info: sync-server: Connection[5]: Session[1]: Session initiated (session_ident=1).
2016-10-29T03:09:06.789Z - info: sync-server: Connection[5]: Session[1]: Received: BIND(server_path=/72c5a/realmtasks, signed_user_token='...xxm/7UjDkuEqQ==', need_file_ident_pair=0)
2016-10-29T03:09:06.789Z - info: sync-server: Connection[5]: Session[1]: Received: IDENT(server_file_ident=21314, client_file_ident=1, client_file_ident_secret=1477, scan_server_version=2, scan_client_version=2, latest_server_version=2, latest_server_session_ident=1643)
2016-10-29T03:09:17.069Z - info: sync-server: Connection[5]: Session[1]: Session terminated (session_ident=1).
2016-10-29T03:09:17.070Z - info: sync-server: Connection[5]: Connection closed by client: End of input
2016-10-29T03:09:26.769Z - info: sync-server: Connection[6]: Connection from 127.0.0.1:58866
2016-10-29T03:09:26.895Z - info: sync-server: Connection[6]: Received: CLIENT(protocol_version=15, client_info_size=2, client_info='{}')
2016-10-29T03:09:27.053Z - info: sync-server: Connection[6]: Session[1]: Session initiated (session_ident=1).
2016-10-29T03:09:27.053Z - info: sync-server: Connection[6]: Session[1]: Received: BIND(server_path=/a4fdec5a/realmtasks, signed_user_token='...K0k7mw==', need_file_ident_pair=0)
2016-10-29T03:09:27.053Z - info: sync-server: Connection[6]: Session[1]: Received: IDENT(server_file_ident=21094, client_file_ident=1, client_file_ident_secret=14907, scan_server_version=2, scan_client_version=2, latest_server_version=2, latest_server_session_ident=164553)
对象服务器正在运行,我可以看到 task 和 taskList 表,但我无法将记录写入表。
当我检查时,auth.log
我得到以下信息
Nov 1 10:53:22 digitalocean sshd[13684]: PAM 2 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=221.229.172.111 user=root
Nov 1 10:53:49 digitalocean sshd[13701]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=221.229.172.111 user=root
Nov 1 10:53:50 digitalocean sshd[13701]: Failed password for root from 221.229.172.111 port 43992 ssh2
Nov 1 10:53:55 digitalocean sshd[13701]: message repeated 2 times: [ Failed password for root from 221.229.172.111 port 43992 ssh2]
Nov 1 10:53:55 digitalocean sshd[13701]: Received disconnect from 221.229.172.111 port 43992:11: [preauth]
Nov 1 10:53:55 digitalocean sshd[13701]: Disconnected from 221.229.172.111 port 43992 [preauth]
Nov 1 10:53:55 digitalocean sshd[13701]: PAM 2 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=221.229.172.111 user=root