Couchbase Lite/Cordova Timeout

Hello out there,

currently I’m struggling with a timeout problem using the CBLite Cordova plugin (CBLite 1.4.1) and the Sync Gateway (1.5).

My setup is similar to the one in this outdated post: How do I configure nginx as a reverse proxy with SSL for sync gateway so that heartbeats work?

I am running the app on a mobile client (android), which communicates with a nginx reverse proxy. The reverse proxy then passes the client requests to the sync gateway. The client, the reverse proxy and the sync gateway are running on physically seperated hosts.

Whenever I start a replication the initial sync (empty client database is populated with the server contents) works fine, however after this initial sync the client throws timeout exceptions.

Examining the packets using Wireshark I came up with the following results:

  • every ~30 sec the client sends a POST request (

  • the reverse proxy passes this request to the sync gateway

  • after 40(!)sec the sync gateway sends a response (the heartbeat?)

  • as the client times out after 30 seconds (default) the TCP connection is broken and the reverse proxy does not pass the gateways response to the client

  • the client starts a new request as in step one

Now this leads me to my questions:

  • how can I get my setup to work? Do you have any experiences with this?
  • how can I adjust the heartbeat value? Browsing the doc, it should be enough to include the heartbeat parameter in the replication request but the code seems to ignore it

I am open to any suggestions and questions.

Thank you very much in advance!

Alright, I just walked into the right colleague, who pointed me to this article:

Solved the problem. Seems, that nginx closes the connections before the heartbeats are sent. Increasing the timeouts in the nginx configuration did the trick.

keepalive_timeout       360s;
proxy_read_timeout      360s;
1 Like