_changes?feed=websocket does not work with cbl1.2

Hi,

I am using cbl 1.2.1 for ios from git hub
Couchbase Sync Gateway/1.2.0(79;9df63a5)"
CBS Version: 4.0.0-4051 Enterprise Edition (build-4051)

In iOS 9 when iOS CBL sdk hits server as http or https for changes (_changes?feed=websocket) some devices get response, but when i use a rest client (POST request) to hit the syncgateway i can see changes.

For same settings Android sdk 1.2.0 is syncing and running smoothly even behind reverse proxy as well as via normal http protocol. Issue with erratic sync or no sync at all is limited to iOS9 with cbl 1.2+.
everything was working fine when we were using 1.1 for ios sdk and sync gateway 1.1

The sync is erratic as sync starts and stops erratically. Works only 50 percent of the time. The old version still works but has other crash issue which makes it unusable.

1 Can we change feed=websocket to continuous or any other parameter in ios sdk.

2 Anything i can change in sync config to rectify this

Please help us out as this is a show stopper for us, any help will be appreciated.

Thanks
Arjun

@arjunblue

As a workaround you can change your iOS client to use pull replication continuous feed type rather than websockets.

See ToDoLite-iOS for a complete example of how to do this.

e.g. in AppDelegate.m

#define kSyncGatewayWebSocketSupport NO

When configuring the pull replication disable websockets

NSURL *syncUrl = [NSURL URLWithString:kSyncGatewayUrl];
        _pull = [self.database createPullReplication:syncUrl];
        _pull.continuous  = YES;
        if (!kSyncGatewayWebSocketSupport) {
            _pull.customProperties = @{@"websocket": @NO};
        }

Are the clients that fail from a random group, or might they only be the ones using HTTPS and WebSockets together.

Which reverse proxy are you using, is the primary purpose of the reverse proxy to terminate TLS (HTTPS) connections? We have some sample configs for nginx

Hi,

-its failing even without http.

  • i am using nginx and its config is as per your link i.e documentation (just rechecked to be sure) will try the workaround and revert .

million thanks for such fast and adept reply
arjun

Hi,

its still not working. ios device is pushing data to server but its not getting change feed.

please find below error log from xcode maybe they can help.

2016-04-01 20:24:30.853 hexa[1735:745234] Sync: CBLRestPuller[https://user:@xxxxxxxx:9443/xxxxxxxx]: Replicating from lastSequence=15987880
2016-04-01 20:24:30.858 hexa[1735:745234] SyncVerbose: CBLRestPuller[https://user:
@xxxxxxxx:9443/xxxxxxxx] starting ChangeTracker: mode=0, since=15987880
2016-04-01 20:24:30.862 hexa[1735:745234] ChangeTracker: CBLSocketChangeTracker[0x157e8500 xxxxxxxx]: Starting…
2016-04-01 20:24:30.864 hexa[1735:745234] SyncVerbose: CBLSocketChangeTracker[0x157e8500 xxxxxxxx]: POST //user:user@xxxxxxxx:9443/xxxxxxxx/_changes
2016-04-01 20:24:30.873 hexa[1735:745234] ChangeTracker: Changes feed using proxy settings {
ExceptionsList = (
".local",
“169.254/16”
);
FTPPassive = 1;
SCOPED” = {
en0 = {
ExceptionsList = (
"
.local",
“169.254/16”
);
FTPPassive = 1;
};
};
}
2016-04-01 20:24:30.878 hexa[1735:745234] ChangeTracker: CBLSocketChangeTracker[0x157e8500 xxxxxxxx]: Started… https://user:*****@xxxxxxxx:9443/xxxxxxxx/_changes
2016-04-01 20:24:30.880 hexa[1735:745234] ChangeTracker: CBLSocketChangeTracker[0x157e8500 xxxxxxxx]: Event 1 on <__NSCFInputStream: 0x168b2220>
2016-04-01 20:24:31.055 hexa[1735:745234] ChangeTrackerVerbose: CBLSocketChangeTracker[0x157e8500 xxxxxxxx]: HasBytesAvailable <__NSCFInputStream: 0x168b2220>
2016-04-01 20:24:31.070 hexa[1735:745088] Sync: CBLReplication[to https://user:*****@xxxxxxxx:9443/xxxxxxxx]: idle, progress = 0 / 0, err: (null)

– Please find my nginx config (running in docker port 9443)

upstream sync_gateway {
server 10.0.6.3:4984;
}

server {
listen 80;
server_name sub.example.com;
client_max_body_size 20m;
location / {
proxy_pass http://sync_gateway;
proxy_pass_header Accept;
proxy_pass_header Server;
proxy_http_version 1.1;
keepalive_requests 1000;
keepalive_timeout 360s;
proxy_read_timeout 360s;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection “upgrade”;
}
}

server {
listen 443 ssl;
server_name sub.example.com;
client_max_body_size 20m;
ssl on;
ssl_certificate /xxxxx/crt.crt;
ssl_certificate_key /xxxx/crrrt.key;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
ssl_protocols TLSv1;
location / {
proxy_pass http://sync_gateway;
proxy_pass_header Accept;
proxy_pass_header Server;
proxy_http_version 1.1;
keepalive_requests 1000;
keepalive_timeout 360s;
proxy_read_timeout 360s;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection “upgrade”;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Ssl on;
}
}

Thanks again
Arjun

@arjunblue

Can you set the the following root property in your Sync Gateway config:

`“log”:["*"],

Then restart Sync Gateway and rerun a pull sync from one of the failing clients and post the Sync Gateway logs.

Thanks @andy your fix to change websocket to no in AppDelegate.m worked after i restarted the sync gateway.

Million thanks andy
Arjun