Hi,
After integrating Couchbase lite framework with iOS app, and running the app in Simulator, getting the following error in Xcode console:
2019-05-13 10:23:01.038849-0500 EventDrivenPattern[59750:846411] CouchbaseLite Replicator ERROR: {Repl#2} Got LiteCore error: WebSocket error 404 “Object Not Found”
Error code :: 10404
Error code :: 10404
I have seen some existing answers and it is talking about adding proper database name
databasename
in the URL.
Following is the code, and i think i added the URL in correct manner.
import UIKit
import CouchbaseLiteSwift
class ViewController: UIViewController {
override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. setupCouchbase () } func setupCouchbase () { // Get the database (and create it if it doesn’t exist). let database: Database do { database = try Database(name: "eventdriven") } catch { fatalError("Error opening database") } // Create a new document (i.e. a record) in the database. let mutableDoc = MutableDocument() .setFloat(2.0, forKey: "version") .setString("SDK", forKey: "type") // Save it to the database. do { try database.saveDocument(mutableDoc) } catch { fatalError("Error saving document") } // Update a document. if let mutableDoc = database.document(withID: mutableDoc.id)?.toMutable() { mutableDoc.setString("Swift", forKey: "language") do { try database.saveDocument(mutableDoc) let document = database.document(withID: mutableDoc.id)! // Log the document ID (generated by the database) // and properties print("Document ID :: \(document.id)") print("Learning \(document.string(forKey: "language")!)") } catch { fatalError("Error updating document") } } // Create a query to fetch documents of type SDK. let query = QueryBuilder .select(SelectResult.all()) .from(DataSource.database(database)) .where(Expression.property("type").equalTo(Expression.string("SDK"))) // Run the query. do { let result = try query.execute() print("Number of rows :: \(result.allResults().count)") } catch { fatalError("Error running the query") } // Create replicators to push and pull changes to and from the cloud. let targetEndpoint = URLEndpoint(url: URL(string: "ws://127.0.0.1:8091/eventdriven")!) let replConfig = ReplicatorConfiguration(database: database, target: targetEndpoint) replConfig.replicatorType = .pushAndPull // Add authentication. replConfig.authenticator = BasicAuthenticator(username: "xxxxxx", password: "yyyyy") // Create replicator. let replicator = Replicator(config: replConfig) // Listen to replicator change events. replicator.addChangeListener { (change) in if let error = change.status.error as NSError? { print("Error code :: \(error.code)") } } // Start replication. replicator.start() }
}
Below is the screenshot of the Couchbase server console: