Document conflict/race condition from .NET push replication

I am attempting to re-authenticate a push replication when an “Unauthorized” HttpException is available in the replication changed event arguments.

It appears that simply resetting the cookie by calling Replication.SetCookie does not re-authenticate the replication. I also tried to remove the previous cookie and then call SetCookie again, which also does not work. This continues to produce unauthorized exceptions.

If I stop the replication, create a brand new instance and then start it again, it seems to work.

However, about 95% of the time when I do this, the replication will then immediately fail with a document conflict when it tries to push up a revision that it tried to push previously but couldn’t due to being unauthorized.

I can send the full output and sequence of events that CBL is logging if that would be helpful. Also, not sure if I should post this to the public forum or if its ok message you directly.

Posting here is fine.

Are you sure you’re getting the “Unauthorized” from a push and not a pull?

What about stopping the replication, setting the cookie, then restarting (without creating a new replication)? (Not sure from your description if that’s what you did.)

I think a code snippet that replicates the behavior would be more helpful than logs, but both is good.