Unable to sync data from syncgateway installed in different machine.
Throwing websocket error 1008
@remya_rt I am sorry that you are having issues with syncgateway. Can you please share your sync gateway version, log and any other information that you have about the usecase
Hi Raju,
I am able to download documents when i installed Syncgateway in my system.
Using : Syncgateway 2.1
When I am accessing Syncgateway installed in different machine ,
I am getting the following error
2019-04-01 11:31:56.265426+0530[3192:62571] CouchbaseLite WS WARNING: {C4SocketImpl#1}==> litecore::repl::C4SocketImpl ws://syngatewayIP_address:4985/_admin/db/databasename/_blipsync
2019-04-01 11:31:56.267395+0530 [3192:62571] CouchbaseLite WS WARNING: {C4SocketImpl#1} Unexpected or unclean socket disconnect! (reason=WebSocket status, code=1008)
2019-04-01 11:31:56.278205+0530 [3192:62492] CouchbaseLite Sync ERROR: {Repl#1}==> litecore::repl::Replicator ~/Library/Developer/CoreSimulator/Devices/B061C592-62D3-424F-86A3-72EDBC9B7BF7/data/Containers/Data/Application/B80C2603-F250-4453-AA0E-05085D9D573A/Library/Application Support/CouchbaseLite/rmamobile_bucket.cblite2/ ->ws://syngatewayIP_address:4985/_admin/db/rmamobile_bucket/_blipsync
2019-04-01 11:31:56.278429+0530 [3192:62492] CouchbaseLite Sync ERROR: {Repl#1} Got LiteCore error: OK (6/1008)
Completed syncing documents
Error code :: Error Domain=CouchbaseLite Code=11008 “OK” UserInfo={NSLocalizedDescription=OK}
Code sniffet
guard let database = self?.database else { return}
// guard let syncURL = URL(string: "ws://localhost:4984/dbname") else { return }
guard let syncURL = URL(string: "ws://sync_gateway_IP_Address:4985/_admin/db/dbname") else { return }
let syncEndpoint = URLEndpoint(url: syncURL)
let replicatorConfig = ReplicatorConfiguration(database: database, target: syncEndpoint)
replicatorConfig.continuous = true
replicatorConfig.replicatorType = .pushAndPull
// Add authentication.
replicatorConfig.authenticator = BasicAuthenticator(username: "sync_gateway", password: "password")
self!.replicator = Replicator(config: replicatorConfig)
self?.replicator?.addChangeListener { (change) in
let status = change.status
switch status.activity {
case .busy:
print("Busy transferring data")
case .connecting:
print("Connecting to Sync Gateway")
case .idle:
print("Replicator in Idle state")
case .offline:
print("Replicator in offline state")
case .stopped:
print("stopped syncing documents")
}
if let error = status.error as NSError? {
print("Error code :: \(error.description)")
} else if status.progress.completed == status.progress.total {
print("All documents synced")
DispatchQueue.main.async {
NotificationCenter.default.post(name: .dbUpdated, object: nil)
}
} else {
print("Documents \(status.progress.total - status.progress.completed) still pending sync")
}
}
self?.replicator?.start()
Thanks
Hi @remya_rt , this issue you encountered looks like connection issue. Question, are you able to access ws://syngatewayIP_address:4985 from your client machine’s web browser?
Yes I can access from your client machine’s web browser
Connecting to Sync Gateway
All documents synced 0
2019-04-25 08:14:47.551990+0530 [39617:3381788] CouchbaseLite WS WARNING: {C4SocketImpl#1}==> litecore::repl::C4SocketImpl ws:/syngatewayIP_address:4985//_blipsync
2019-04-25 08:14:47.552223+0530 [39617:3381788] CouchbaseLite WS WARNING: {C4SocketImpl#1} Unexpected or unclean socket disconnect! (reason=WebSocket status, code=1008)
2019-04-25 08:14:47.560058+0530 [39617:3381672] CouchbaseLite Sync ERROR: {Repl#1}==> litecore::repl::Replicator /Users/Library/Developer/CoreSimulator/Devices/A647D894-F56D-4916-8347-EE7CC78DBBE8/data/Containers/Data/Application/3CDA8A03-A25F-4CC3-BF3B-10B04E2FAE99/Library/Application Support/CouchbaseLite/rmamobile_bucket.cblite2/ ->ws:/syngatewayIP_address:4985//_blipsync
2019-04-25 08:14:47.560292+0530[39617:3381672] CouchbaseLite Sync ERROR: {Repl#1} Got LiteCore error: OK (6/1008)
Completed syncing documents
Error code :: 11008