When generating unique sequency getting Timed out after 30000 ms while waiting for a server that matches WritableServerSelector.
Hi John,
Based on the error message that you provided, it just means that the client couldn’t find a suitable server for write operations. The log says address=localhost:27017, type=REPLICA_SET_SECONDARY, so likely because you’re connecting directly to a secondary replica set member. Clients cannot write data to secondaries, clients can only read data from secondary members.
Try specifying the replica set connection string: mongodb://localhost:27017,localhost:<SOME PORT>,localhost:<SOME OTHER PORT>/admin?replicaSet=<REPLICASET NAME>. See also MongoDB Java driver: Make a Connection and MongoDB Connection String.
If you have further questions related to MongoDB and/or MongoDB Java driver please provide:
Regards,
Wan.