You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I start my application, I see the following error in logs:
com.mongodb.MongoSocketException: localhostsomehost
at com.mongodb.ServerAddress.getSocketAddresses(ServerAddress.java:217) ~[mongodb-driver-core-4.9.1.jar:na]
at com.mongodb.internal.connection.SocketStream.initializeSocket(SocketStream.java:78) ~[mongodb-driver-core-4.9.1.jar:na]
at com.mongodb.internal.connection.SocketStream.open(SocketStream.java:68) ~[mongodb-driver-core-4.9.1.jar:na]
at com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:204) ~[mongodb-driver-core-4.9.1.jar:na]
at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.lookupServerDescription(DefaultServerMonitor.java:199) ~[mongodb-driver-core-4.9.1.jar:na]
at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:159) ~[mongodb-driver-core-4.9.1.jar:na]
at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]
Caused by: java.net.UnknownHostException: localhostsomehost
at java.base/java.net.InetAddress$CachedAddresses.get(InetAddress.java:801) ~[na:na]
at java.base/java.net.InetAddress$NameServiceAddresses.get(InetAddress.java:887) ~[na:na]
at java.base/java.net.InetAddress.getAllByName0(InetAddress.java:1533) ~[na:na]
at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1385) ~[na:na]
at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1306) ~[na:na]
at com.mongodb.ServerAddress.getSocketAddresses(ServerAddress.java:209) ~[mongodb-driver-core-4.9.1.jar:na]
... 6 common frames omitted
I've found that in PropertiesMongoConnectionDetails class connection string (getConnectionString() function) is being built and comma is missing between host value and first additional host value:
wilkinsona
changed the title
MongoDB additional-hosts UnknownHostException
Connecting to Mongo fails with an UnknownHostException when spring.data.mongodb.additional-hosts is configured
Jul 18, 2023
I have some MongoDB config with Spring boot:
When I start my application, I see the following error in logs:
I've found that in PropertiesMongoConnectionDetails class connection string (getConnectionString() function) is being built and comma is missing between host value and first additional host value:
String.join(",", this.properties.getAdditionalHosts()) will insert comma between additional-hosts values, but not at the start
The text was updated successfully, but these errors were encountered: