I have done a sample project using Couchbase Lite(CouchBaseLite Version = “3.2.1”) in my Android Project. However, P2P sync is not happening even though all the steps mentioned in the documentation are handled properly. I am getting a couchbaseLite Exception during Replication.
Here is the error :
state changed BUSY => STOPPED(0/0) CouchbaseLiteException{ CouchbaseLite, 26: Invalid getCollections message: not the first message at com.couchbase.lite.ReplicatorStatus. convertC4StatusError( ReplicatorStatus. java: 63) at com.couchbase.lite.ReplicatorStatus. < init> ( ReplicatorStatus. java: 88) at com.couchbase.lite.AbstractReplicator. updateStatus( AbstractReplicator. java: 797) with tag CouchbaseLite/REPLICATOR
Also getting following log in between -
Obj=/JRepl@1954722883/C4RemoteRepl#10/Repl#11/ Got error response: BLIP 400 ‘Invalid getCollections message: not the first message’
Are the apps on both devices using the same version of CBL?
Are you using only the default collection, or multiple collections? Do the databases on each device have the same collections configured?
Did you remember to specify which collection(s) to replicate?
(This error is coming from the replication protocol at a pretty low level. I wouldn’t expect it to be visible to the app, and it looks like something that could be a protocol version mismatch, or else a disagreement between the peers about whether they’re syncing non-default collections.)
Hi krinyny,
Thanks for your posting. Is it possible to collect the logs at the Verbose level? I would like to have the logs on both devices (active and passive) ?
Are the apps on both devices using the same version of CBL? - Yes same version (3.2.1)
Are you using only the default collection, or multiple collections? Do the databases on each device have the same collections configured? - I have a created one collection and used the same collection. Databases on each device have same collection (collection Name is User)
Did you remember to specify which collection(s) to replicate? - Yes, I have specified the collection in Replicator Config. Below is the code
val replicator = Replicator(
ReplicatorConfigurationFactory.newConfig(
target = messageEndPoint,
collections = mapOf(db.collections to null),
type = ReplicatorType.PUSH_AND_PULL
)
)
Hi @krinyny thank you for your time to collect the logs. I found that in the ActivePeerLogs, there are BLIP messages, such as " SENDING: REQ #0", but in PassivePeerLogs, the logs ended without any BLIP messages. Can you double check the logs from the Passive Peer? Who does the Active Peer talk to?
After checking the Passive Logs,
I found - Received Data: !Error-Domain??BLIP??Error-Code??400??Invalid getCollections message: not the first messaget���
I have only two devices which are running same app.
In the logs, I see ActivePeer is connected to NearbyServer
Yes, I did see those. But after “Connected!” at 2025-03-20 11:00:20.472 in PassivePeer.txt, there are only 4 lines, finishing at 2025-03-20 11:00:20.474.
In ActivePeer.txt, there are still many activities after “Connected!”. The last interesting log is at 2025-03-20 11:00:21.880. No evidence ActivePeer was talking with the PassivePeer after “Connected!”
ActivePeer sent out “getCollections”, but no evidence the PassivePeer received it. ActivePeer received ERR#1, but no evidence the PassivePeer sent it.
I also see ActivePeer received “getCollection”, which is not correct, but don’t know where it came from.
From our engineer looking into the issue and the source code provided:
The Android app looks strange for the p2p issue. It looks like every time they send a message on either side (passive or active) they call “receive” on the same connection. Not sure what they are trying to do, but it looks like any message that gets sent is going to echo right back to where it came from…
Basically, the current code is reverting the message sent to the remote server (remote replicator) back to the local replicator which is not correct. The replicatorConnection.receive(message) is for forwarding the message gotten from the remote server to the local replicator. Please fix that first and try to reproduce the issue again.
Are you implementing a new type of network transport? That’s about the only reason to use those MessageEndpoint APIs. I’m curious because almost no one has ever used those before. Most people just use the normal replicator.