PouchDB ETIMEDOUT error

2019-07-11 03:40发布

So we've been building an app that uses couchDb/cloudant with Pouchdb as our driver client side (ionic framework) and server side (node).

Of late we've been getting errors when connecting to the remote, that seem to appear at random and only disappear temporarily restarting the app, or opening a new browser.

update-data.service.js:38 Error: ETIMEDOUT(…)(anonymous function) @ update-data.service.js:38processQueue @ angular.js:16383(anonymous function) @ angular.js:16399$eval @ angular.js:17682$digest @ angular.js:17495(anonymous function) @ angular.js:17721completeOutstandingRequest @ angular.js:5964(anonymous function) @ angular.js:6243

When running in incognito browser though temporarily removed the issue (or seperate browser) but the error always comes back.

Starting and stopping couch seems to also temporarily solve the problem.

Issue comes up unpredictably when running as an app (both android and ios) with cloudant as the backend

Have not seen it yet on node.js server.

Any possible avenues or directions that we could explore?

1条回答
smile是对你的礼貌
2楼-- · 2019-07-11 04:18

I have these ETIMEDOUT errors from PouchDB when the HTTP request to a remote database cannot be done, presumably because of a poor internet connection.

If there is up and downs in your connection you can try to increase the duration before a timeout error is thrown (see the options for remote databases in the doc):

var remote = new PouchDB('address', {
  ajax: {
    timeout: 60000,
  }
});

In the above example, a timeout error will be thrown only if the HTTP request cannot be done for 60 seconds.

查看更多
登录 后发表回答