couchdbreplicationdatabase-replicationcouchappcouchdb-futon

CouchDB {error,req_timedout}


Somehow I cant bring my local couchdb into replication with a remote server... I always see in the logs:

[error] [<0.5607.0>] Replicator, request GET to "http://admin:*****@mydomain.com/couchdb/apps/_changes?feed=continuous&style=all_docs&since=12&heartbeat=10000" failed due to error {error,req_timedout}
[info] [<0.5607.0>] Retrying _changes request to source database http://admin:*****@mydomain.com/couchdb/apps/ with since=12 in 2.0 seconds

But when I query with my browser the url (without the continous parameter)

http://admin:*****@mydomain.com/couchdb/apps/_changes?style=all_docs&since=12&heartbeat=10000

I can connect without problems... If I set the timeout higher (f.e. 90 seconds) it doesnt change anything.. Before I tried it via HTTPS, and it didn't work, so i tried it now with HTTP.. In Browser fine, in local CouchDB not working.. :(

My replication document seems like this:

{
   "_id": "ab0c55f3a60057835c079f58360042de",
   "_rev": "2-34cd32e7cada589095a1868bc54e5fce",
   "source": "http://admin:xxxxx@mydomain.com/couchdb/apps",
   "target": "apps",
   "connection_timeout": 30000,
   "continuous": true,
   "owner": "admin",
   "_replication_state": "triggered",
   "_replication_state_time": "2014-08-02T19:43:50+02:00",
   "_replication_id": "06beb828bd5b9d4a78bfc3e049b0bb9c"
}

And it shows that the replicator is running in the status console, but in the log I get the error message above. Do you maybe have a hint?


Solution

  • Damn.. I forgott to include to turn the buffering off in nginx:

    See http://wiki.apache.org/couchdb/Nginx_As_a_Reverse_Proxy

    Continuous Replication through nginx

    The above configuration will break the continuous replication. By adding the following snippet the replication will work again:

     location ~ ^/(.*)/_changes {
         proxy_pass http://localhost:5984;
         proxy_redirect off;
         **proxy_buffering off;**
         proxy_set_header Host $host;
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }
    

    But then I got another error: unauthorized access..

    So I had to add following to my replication document - then it worked:

    "create_target":true,
    "user_ctx": {
        "roles": ["_admin"]
    }