简体   繁体   中英

PouchDB - Live sync got stuck, sometimes?

Introduction

We are using PouchDB 7.2.1 to synchronize a mobile PWA with a CouchDB to build up a Shared Context. In order to achieve this we use the bidirectional sync method from PouchDB. In the following code snippet you can see our parameters.

 PouchDB.sync(
        POUCH_DB,
        `${internalUrl}/couchdb/${POUCH_DB}`,
        {
           auth: {
             username: username,
             password: password
           },
           live: true,
           retry: true
    };

The communication path can be described as:

PWA <---> Nginx (Reverse Proxy) <---> CouchDB (as a Docker-Container)

Description of the problem

PouchDB works well on PCs, iOS and some Android devices. From time to time, the long pool request on an Android device is frozen or does not disconnect, and PouchDB stopped the bidirectional synchronization. The client does not receive no updates anymore . The following snippet shows of the last request, we have recieved at our reverse proxy (nginx).

IP-Address - USER [17/Jan/2023:18:16:07 +0100] "GET /couchdb/dbname/_changes?style=all_docs&feed=longpoll&heartbeat=10000&since=...&limit=1

We have already checked:

  • Session-Timeout
  • Device is offline or not
  • Logs on all PouchDb events
  • Using no reverse proxy

Hopefully, someone have a possible solution for this problem.

Thanks to LyteFM. His comment helped us to isolate the problem. We had a CouchDB Version prior 3.3.0. An upgrade to CouchDB to 3.3.1 solved our problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM