Auto-Generated Field - Timed out after 30000 ms while waiting for replica set

2,592 views
Skip to first unread message

John Wick

unread,
Jun 29, 2019, 8:26:12 PM6/29/19
to mongodb-user

I am using Spring 5 reactive programming. When generating unique sequency getting Timed out after 30000 ms while waiting for a server that matches WritableServerSelector.

I have 3 replica set on my local machine.


{
    "error": "Timed out after 30000 ms while waiting for a server that matches WritableServerSelector. Client view of cluster state is {type=REPLICA_SET, servers=[{address=localhost:27017, type=REPLICA_SET_SECONDARY, roundTripTime=1.3 ms, state=CONNECTED}]; nested exception is com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches WritableServerSelector. Client view of cluster state is {type=REPLICA_SET, servers=[{address=localhost:27017, type=REPLICA_SET_SECONDARY, roundTripTime=1.3 ms, state=CONNECTED}]",
    "cause": "Timed out after 30000 ms while waiting for a server that matches WritableServerSelector. Client view of cluster state is {type=REPLICA_SET, servers=[{address=localhost:27017, type=REPLICA_SET_SECONDARY, roundTripTime=1.3 ms, state=CONNECTED}]"
}

Wan Bachtiar

unread,
Jul 2, 2019, 9:10:30 PM7/2/19
to mongodb-user

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:

  • MongoDB server version
  • MongoDB Java driver version
  • Example code snippet

Regards,
Wan.

Reply all
Reply to author
Forward
0 new messages