[JAVA-2479] could not find host matching read preference { mode: "primary", tags: [ {} ] } Created: 28/Mar/17  Updated: 11/Sep/19  Resolved: 28/Mar/17

Status: Closed
Project: Java Driver
Component/s: Connection Management
Affects Version/s: 3.0.2
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: sulabh Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Linux



 Description   

Hi,

I am getting "Query failed with error code 133" error which looks like comes when there is no primary node available. For this to handle i tried to set ServerSelectionTimeout/SocketTimeout/SoketkeepAlive it didnt work. Can you please tell me which option do i need to give while creating the mongoClient object, So that i can handle the exception with some timeout in my application. Below is the error:

nested exception is org.springframework.data.mongodb.UncategorizedMongoDbException: Query failed with error code 133 and error message 'could not find host matching read preference { mode: "primary", tags: [ {} ] } fo
r set shard_B_0' on server mongo001-mongos-b-0:27018; nested exception is com.mongodb.MongoQueryException: Query failed with error code 133 and error message 'could not find host
matching read preference { mode: "primary", tags: [ {} ] } for set shard_B_0' on server XYZ:27018
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1210)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)



 Comments   
Comment by Ross Lawley [ 28/Mar/17 ]

Hi sulabh84,

Just to let you know this project is for Java driver bugs or feature requests. The best place for questions regarding MongoDB usage or the Java driver specifics is the mongodb-user mailing list or stackoverflow as you will reach a boarder audience there. If your business requires an answer from MongoDB within a set time frame then we do offer production support.

There may also be an appropriate Spring Data forum. It looks like your there is a wrapped exception from SpringData and there might be a Spring specific configuration. Either way, if you do use one of these forums please post a link here and I'll endeavour to follow up there.

All the best,

Ross

Generated at Thu Feb 08 08:57:19 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.