[JAVA-163] Support Unix Domain Sockets Created: 09/Sep/10  Updated: 20/Mar/18  Resolved: 20/Mar/18

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

Type: New Feature Priority: Major - P3
Reporter: Scott Hernandez (Inactive) Assignee: Ross Lawley
Resolution: Done Votes: 6
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on JAVA-941 Introduce Stream abstraction Closed

 Description   

Add support for unix domain sockets (AF_UNIX) – potentially with junixsocket (http://code.google.com/p/junixsocket/)

This dep should probably be done in way where it is optional. This can easily be done by checking for the existence of the classes used for unix domain sockets before using them. This would make it an optional runtime dep.; it will still be a compile time dep.



 Comments   
Comment by Githook User [ 20/Mar/18 ]

Author:

{'email': 'ross.lawley@gmail.com', 'name': 'Ross Lawley', 'username': 'rozza'}

Message: Test: Limit Java version for UnixServerAddress tests

JAVA-163
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/f54b4450a163de1ec3c6094afd6a9be29a28b4dd

Comment by Githook User [ 20/Mar/18 ]

Author:

{'email': 'ross.lawley@gmail.com', 'name': 'Ross Lawley', 'username': 'rozza'}

Message: Complete unix socket support

Ensure jnr library is optional via UnixServerAddress
Added unix socket support to the connection string.

JAVA-163
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/e1680a252ae5122ac77f942eed4625d589d4ec72

Comment by Githook User [ 20/Mar/18 ]

Author:

{'email': 'joan@profuzdigital.com', 'name': 'Joan Karadimov', 'username': 'joankaradimov'}

Message: Support Unix Domain Sockets via jnr-unixsocket

JAVA-163
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/d2ff8e12a3352d76a297178f75177d7093295ebe

Comment by Joan Karadimov [ 18/Sep/17 ]

I've opened this pull request in github with a Unix domain sockets implementation:
https://github.com/mongodb/mongo-java-driver/pull/401

It has the following features:

  • It requires jnr-unixsocket, but it keeps it an optional dependency
  • It does not require the installation of additional native libraries
  • It fails [kind of] gracefully on Windows (error reporting can be improved)
Comment by Boris Petrov [ 07/May/17 ]

Hello,

Sorry for the late answer, I hadn't configured email notifications for this Jira.

Well, there's nothing special in my use case - I want to connect to a local MongoDB instance running on the same machine as the Java application. Unix Domain Sockets have (way?) better performance and throughput than TCP ones, and the connection to a DB is definitely something one would want to optimize, so why not use domain sockets? Is there any reason for this to not be implemented (especially if it's not a big deal)?

Comment by Jeffrey Yemin [ 24/Apr/17 ]

Hi Boris,

No, we don't have any current plans to implement support for Unix Domain Sockets. Can you tell us about your use case for it?

Comment by Boris Petrov [ 24/Apr/17 ]

Any plans for this to be implemented? I tried implementing it only in our code but ServerAddress seems to be hardcoded in too many places and just doing a:

new MongoClient(new ServerAddress(new AFUNIXSocketAddress(new File(host))), ...)

Doesn't work. For example, in version 3.4.2:

https://github.com/mongodb/mongo-java-driver/blob/r3.4.2/driver-core/src/main/com/mongodb/connection/ClusterSettings.java#L106

Maybe if this and similar calls are not using specific overloads of ServerAddress which are for IP/port, domain sockets could be easily implemented in client code.

Comment by Tristan Christopher [ 05/Feb/15 ]

The junixsocket library is evolved since what is shown in http://code.google.com/p/junixsocket/. It no longer requires native library files to be manually placed in the system's java library path. You just need to include these dependencies.

http://mvnrepository.com/artifact/com.kohlschutter.junixsocket/junixsocket-common/2.0.4
http://mvnrepository.com/artifact/com.kohlschutter.junixsocket/junixsocket-native-common/2.0.4

Comment by Jeffrey Yemin [ 12/Jul/13 ]

In principle, should be able to do this with a custom ConnectionFactory in 3.0 branch. See https://github.com/mongodb/mongo-java-driver/blob/3.0.x/driver/src/main/org/mongodb/connection/ConnectionFactory.java. But I doubt we'll put this in the driver directly since it requires a 3rd party library unless we add support for optional dependencies.

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