[JAVA-2852] Domain socket connection doesn't work with the async driver Created: 04/May/18  Updated: 27/Oct/23  Resolved: 21/May/18

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

Type: Bug Priority: Major - P3
Reporter: Boris Petrov Assignee: Unassigned
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to JAVA-2864 Improve domain socket documentation a... Backlog

 Description   

We are using the async driver. I've installed jnr-unixsocket. Then, just replacing:

serverAddress = new ServerAddress(host, port);

With:

serverAddress = new UnixServerAddress("/tmp/mongodb-27017.sock");

Causes:

com.mongodb.MongoTimeoutException: Timed out after 5000 ms while waiting for a server that matches WritableServerSelector. Client view of cluster state is {type=UNKNOWN, servers=[{address=/tmp/mongodb-27017.sock, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoInternalException: Opening the AsynchronousSocketChannelStream failed}, caused by {java.lang.UnsupportedOperationException: Cannot return a InetSocketAddress from a UnixServerAddress}}]
	at com.mongodb.connection.BaseCluster.createTimeoutException(BaseCluster.java:389)
	at com.mongodb.connection.BaseCluster.handleServerSelectionRequest(BaseCluster.java:297)
	at com.mongodb.connection.BaseCluster.access$800(BaseCluster.java:58)
	at com.mongodb.connection.BaseCluster$WaitQueueHandler.run(BaseCluster.java:470)
	at java.lang.Thread.run(Thread.java:748)

It says "Cannot return a InetSocketAddress from a UnixServerAddress" which I guess is some bug.



 Comments   
Comment by Elan Kugelmass [ 26/Jun/18 ]

jeff.yemin could you elaborate on why the Async driver (when used with Netty) is not compatible with domain sockets? Netty does support Domain Socket Channels. https://github.com/netty/netty/pull/3344

Comment by Jeffrey Yemin [ 21/May/18 ]

Closing as Works as Designed, and linked to issue to improve docs and error handling.

Comment by Jeffrey Yemin [ 21/May/18 ]

Linked to JAVA-2864

Comment by Jeffrey Yemin [ 21/May/18 ]

Note: https://github.com/mongodb/mongo-java-driver/commit/a55d172161511132d1be5c6100443065b9444ef2 references this issue but the commit is actually for JAVA-2851

Comment by Jeffrey Yemin [ 04/May/18 ]

Domain sockets are not supported in the async driver.  The implementation relies on jnr-unixsocket, which is essentially a custom socket factory.  But the async driver uses java.nio.channels.AsynchronousSocketChannel or, optionally, Netty, neither of which are compatible with domain sockets.

We don't intend to support this use case, but we'll look into improving the documentation to make it clear that it's not supported, and failing fast rather than waiting for a timeout exception.

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