Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-2479

could not find host matching read preference { mode: "primary", tags: [ {} ] }

    • Type: Icon: Task Task
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.0.2
    • Component/s: Connection Management
    • Labels:
      None
    • Environment:
      Linux

      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)

            Assignee:
            Unassigned Unassigned
            Reporter:
            sulabh84 sulabh
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: