realm / realm-object-server

Tracking of issues related to the Realm Object Server and other general issues not related to the specific SDK's
https://realm.io
293 stars 42 forks source link

ROS doesn't start properly: Unhandled promise rejection - Bad WebSocket handshake #362

Closed joluet closed 6 years ago

joluet commented 6 years ago

I'm running ROS 3.0.0 behind an Nginx proxy. When I try to start the server I see the log below. Afterwards the server seems to be in a nonfunctional state and the clients are not able to sync. Only after restarting the server a couple of times it eventually starts without this error message and then sync is working.

info: Realm Object Server version 3.0.0 is starting
info: [sync] Configuring SyncService with a custom dataPath is deprecated and will be removed in a future version and the value will default to 'sync', relative to the server's dataPath.
info: [sync] Realm sync server started ([realm-core-5.4.0], [realm-sync-3.0.0])
info: [sync] Cluster mode: Root node
info: [sync] Backup mode: disabled
info: [sync] Log level: info
info: [sync] Download log compaction is enabled
info: [sync] Max download size: 131072 bytes
info: [sync] Listening on 127.0.0.1:32834 (sync protocol version 24, max backlog is 128)
info: [sync] HTTP Connection[1]: Connection is closed after HTTP response.
info: [sync] HTTP Connection[2]: Connection is closed after HTTP response.
info: [sync] HTTP Connection[5]: Connection is closed after HTTP response.
info: [sync] HTTP Connection[6]: Connection is closed after HTTP response.
info: [sync] HTTP Connection[7]: Connection is closed after HTTP response.
info: [sync] HTTP Connection[11]: Connection is closed after HTTP response.
info: [sync] HTTP Connection[13]: Connection is closed after HTTP response.
info: [sync] HTTP Connection[15]: Connection is closed after HTTP response.
info: [sync] HTTP Connection[16]: Connection is closed after HTTP response.
info: [sync] HTTP Connection[19]: Connection is closed after HTTP response.
info: [sync] HTTP Connection[21]: Connection is closed after HTTP response.
Detected an unhandled promise rejection at:  Promise {
  <rejected> 'Bad WebSocket handshake response 502-504 received' } , reason:  Bad WebSocket handshake response 502-504 received
Detected an unhandled promise rejection at:  Promise {
  <rejected> 'Bad WebSocket handshake response 502-504 received' } , reason:  Bad WebSocket handshake response 502-504 received
info: Realm Object Server has started and is listening on http://0.0.0.0:9080
Realm Object Server was started on 0.0.0.0:9080
info: [sync] HTTP Connection[23]: Connection is closed after HTTP response.

In the Android clients I see this error:

04-25 22:54:21.075 6309-6452/? W/REALM_JAVA: Unknown error code: 8
04-25 22:54:21.076 6309-6452/? E/REALM_JAVA: Session Error[realms://realm.mydomain.com/6elOkw7dWZY6IplQ5JoutKVBkjO2/default]: UNKNOWN(-1)
    Bad WebSocket handshake response 502-504 received
04-25 22:54:22.079 6309-6452/? E/REALM_SYNC: Connection[1]: Websocket: HTTP response is 502-504
04-25 22:54:22.079 6309-6452/? W/REALM_JAVA: Unknown error code: 8
04-25 22:54:22.080 6309-6452/? E/REALM_JAVA: Session Error[realms://realm.mydomain.com/6elOkw7dWZY6IplQ5JoutKVBkjO2/default]: UNKNOWN(-1)
    Bad WebSocket handshake response 502-504 received
04-25 22:54:22.947 6309-6452/? E/REALM_SYNC: Connection[1]: Websocket: HTTP response is 502-504
04-25 22:54:22.948 6309-6452/? W/REALM_JAVA: Unknown error code: 8

I have these lines in my NginX config

           proxy_set_header Upgrade $http_upgrade;
           proxy_set_header Connection "Upgrade";

As mentioned above the server eventually starts running and then everything is fine. It would just be nice if I could make it start properly right away. Any ideas how to fix this? Is it related to NginX? What does this mean?

Detected an unhandled promise rejection at:  Promise {
  <rejected> 'Bad WebSocket handshake response 502-504 received' } 
joluet commented 6 years ago

Also worth noting, the server is running on a Digital Ocean droplet with 512 MB RAM.

joluet commented 6 years ago

It seem like this was actually related to memory usage. I just resized my droplet to 1 GB RAM and that seems to have fixed the issue. So I'll close this for now.