Sync Gateway odd behaviour

Hi all,

I found some odd behaviour in the sync gateway. So this is a dev config, Couchbase DB and SG both run on a windows dev machine and all traffic routed to the SG via a reverse proxy. All clients of the SG are mobile devices (currently iOS only).

For some reason the connection SG has to Couchbase DB is dropped randomly (which is not itself the issue) and the SG correctly reports that it will attempt to reconnect:

_time=2016-12-09T19:22:45.983+00:00 _level=INFO _msg=go-couchbase: TAP connection lost; reconnecting to bucket "ketodiet" in 1s

However, while it’s ‘offline’ it keeps processing requests which of course fail, here’s an example:

2016-12-09T19:22:46.385Z HTTP:  #40902: GET /ketodiet/CM_8780ACDBEFB743178D79A10EAC4079FC?rev=2-53c9c70ab79a019d708c8fee093f39b4&revs=true&attachments=true
2016-12-09T19:22:46.385Z HTTP: #40902:     --> 401 Invalid login  (3.0 ms)
2016-12-09T19:22:46.385Z HTTP auth failed for username="18844"

Eventually it reconnects and syncing appears to resume as expected

_time=2016-12-09T19:22:48.588+00:00 _level=INFO _msg=Got new configuration for bucket ketodiet
2016-12-09T19:22:50.519Z HTTP:  #40910: GET /ketodiet/CBM_34720f88-4174-403a-916d-5e6a8ef116b5?rev=2-dfa047650b3ea31648c400bfb663e00a&revs=true&attachments=true  (as 18844)

The problem is that for whatever reason, changes are not sent down to mobile devices until the SG is restarted. So making changes on a mobile device will PUT documents correctly but the changes are never triggered/ sent to other connected devices. Restarting the SG fixes that.

Any idea what is going on? Is this a known issue? Are there any workarounds?

At the moment I’m thinking of handling 401s on our reverse proxy and re-trying the requests.

Thank you

Some more info on this - the memcached service seems to be crashing on windows and the 401s on the SG seem to coincide with the crashes - which is strange as memcached is not used.

On the bright side, the service is now running on a test server on ec2 and seems to be very stable. So I would think this is just a windows distr issue.


@nkonstas would you mind opening a ticket on this in github? Thanks. -Hod

Hi Hod, sorry it took me so long to reply – which project should I raise this against? Is it: ?


I think instead, to start. Also, I noticed the log about getting a new configuration on reconnecting. Seems like something worth mentioning when creating the issue.


@hod.greeley I downloaded dev version 4.6.0 and this issue has been resolved. Apparently it had to do with memcached crashing on windows. Here’s a blog post about it:

Thank you

1 Like