com.mongodb.MongoException: host and port should be specified in host:port format

JIRA | Mark Paluch | 6 months ago
  1. 0

    Constructing a {{ServerAddress}} using IPv6 {{InetAddress}} fails if the specified IP address resolves to its address (i.e. no reverse host mapping). {{ServerAddress}} assumes that IPv6 addresses are always specified in brackets which isn't the case for IPv6 addresses without reverse host mapping. Stack trace: {code} com.mongodb.MongoException: host and port should be specified in host:port format at com.mongodb.ServerAddress.<init>(ServerAddress.java:122) at com.mongodb.ServerAddress.<init>(ServerAddress.java:58) {code} Test case: {code:java} import static org.junit.Assert.*; import java.net.InetAddress; import org.junit.Test; import com.mongodb.ServerAddress; public class ServerAddressUnitTests { @Test public void hostAndPortStringIPv6AddressShouldWork() throws Exception { ServerAddress serverAddress = new ServerAddress("[dead:beef:affe::1]:27017"); assertEquals(27017, serverAddress.getPort()); assertEquals("dead:beef:affe::1", serverAddress.getHost()); } @Test public void hostAndPortIPv6AddressShouldWork() throws Exception { ServerAddress serverAddress = new ServerAddress("[dead:beef:affe::1]", 27017); assertEquals(27017, serverAddress.getPort()); assertEquals("dead:beef:affe::1", serverAddress.getHost()); } @Test public void inetAddressIPv6AddressShouldWork() throws Exception { ServerAddress serverAddress = new ServerAddress(InetAddress.getByName("dead:beef:affe::1")); assertEquals(27017, serverAddress.getPort()); assertEquals("dead:beef:affe::1", serverAddress.getHost()); } @Test public void inetAddressAndPortIPv6AddressShouldWork() throws Exception { ServerAddress serverAddress = new ServerAddress(InetAddress.getByName("dead:beef:affe::1"), 27017); assertEquals(27017, serverAddress.getPort()); assertEquals("dead:beef:affe::1", serverAddress.getHost()); } } {code}

    JIRA | 6 months ago | Mark Paluch
    com.mongodb.MongoException: host and port should be specified in host:port format
  2. 0

    Constructing a {{ServerAddress}} using IPv6 {{InetAddress}} fails if the specified IP address resolves to its address (i.e. no reverse host mapping). {{ServerAddress}} assumes that IPv6 addresses are always specified in brackets which isn't the case for IPv6 addresses without reverse host mapping. Stack trace: {code} com.mongodb.MongoException: host and port should be specified in host:port format at com.mongodb.ServerAddress.<init>(ServerAddress.java:122) at com.mongodb.ServerAddress.<init>(ServerAddress.java:58) {code} Test case: {code:java} import static org.junit.Assert.*; import java.net.InetAddress; import org.junit.Test; import com.mongodb.ServerAddress; public class ServerAddressUnitTests { @Test public void hostAndPortStringIPv6AddressShouldWork() throws Exception { ServerAddress serverAddress = new ServerAddress("[dead:beef:affe::1]:27017"); assertEquals(27017, serverAddress.getPort()); assertEquals("dead:beef:affe::1", serverAddress.getHost()); } @Test public void hostAndPortIPv6AddressShouldWork() throws Exception { ServerAddress serverAddress = new ServerAddress("[dead:beef:affe::1]", 27017); assertEquals(27017, serverAddress.getPort()); assertEquals("dead:beef:affe::1", serverAddress.getHost()); } @Test public void inetAddressIPv6AddressShouldWork() throws Exception { ServerAddress serverAddress = new ServerAddress(InetAddress.getByName("dead:beef:affe::1")); assertEquals(27017, serverAddress.getPort()); assertEquals("dead:beef:affe::1", serverAddress.getHost()); } @Test public void inetAddressAndPortIPv6AddressShouldWork() throws Exception { ServerAddress serverAddress = new ServerAddress(InetAddress.getByName("dead:beef:affe::1"), 27017); assertEquals(27017, serverAddress.getPort()); assertEquals("dead:beef:affe::1", serverAddress.getHost()); } } {code}

    JIRA | 6 months ago | Mark Paluch
    com.mongodb.MongoException: host and port should be specified in host:port format
  3. 0

    [Bug] When using on Spark2.x with hadoop 2.7.x, Error occur as following

    GitHub | 2 months ago | DeeeFOX
    com.mongodb.MongoException: host and port should be specified in host:port format
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    [Bug] When using on Spark2.x with hadoop 2.7.x, Error occur as following

    GitHub | 2 months ago | DeeeFOX
    com.mongodb.MongoException: host and port should be specified in host:port format
  6. 0

    com.mongodb.MongoException: host and port should be specified in host:port format

    GitHub | 7 months ago | ziapapa
    com.mongodb.MongoException: host and port should be specified in host:port format

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. com.mongodb.MongoException

      host and port should be specified in host:port format

      at com.mongodb.ServerAddress.<init>()
    2. MongoDB Java Driver
      ServerAddress.<init>
      1. com.mongodb.ServerAddress.<init>(ServerAddress.java:122)
      2. com.mongodb.ServerAddress.<init>(ServerAddress.java:58)
      2 frames