Skip to content

Support unix domain socket connections #181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mp911de opened this issue Oct 15, 2019 · 4 comments
Closed

Support unix domain socket connections #181

mp911de opened this issue Oct 15, 2019 · 4 comments
Labels
type: enhancement A general enhancement
Milestone

Comments

@mp911de
Copy link
Collaborator

mp911de commented Oct 15, 2019

It would make sense to support unix domain sockets as connection addresses in addition to host/port-based addressing.

Using PostgresqlConnectionConfiguration, we could introduce a socket(…) configuration method to configure the socket endpoint.

For PostgresqlConnectionFactoryProvider, we could have a Option.valueOf("socket") that configures the socket to use.

Probably we don't have a good way how to configure the socket using URL-based connection strings as we assume <host>[/<database>] as pattern. The path does not provide any information about whether the last segment is a database name or whether it belongs to the socket. At configuration time, the socket might not even be available so a exists check cannot be used to disambiguate the string.

Related issue: spring-projects/spring-data-r2dbc#192

@mp911de mp911de added the type: enhancement A general enhancement label Oct 15, 2019
@mirromutth
Copy link

mirromutth commented Oct 16, 2019

How about r2dbc:postgresql:unix:///absolute/path/to/xxx.sock[/<database>]? Relative path will like r2dbc:postgresql:unix://relative/path/to/xxx.sock[/<database>] or r2dbc:postgresql:unix://./relative/path/to/xxx.sock[/<database>] (In other words, protocol is unix, path end by last .sock)

May be useful: SSLSessionHandlerAdapter#operationComplete() cast the type of channel.remoteAddress() result to be InetSocketAddress when SSLMode is VERIFY_FULL, because it need verify the hostname.

So, VERIFY_FULL should be unavailable when using unix domain socket.

@mp911de
Copy link
Collaborator Author

mp911de commented Oct 16, 2019

Although MySQL uses the .sock scheme, there's really nothing that would enforce it. So let's keep the URL variant out of scope for now. I was also wondering about SSL. Probably we don't need SSL, I haven't investigated yet what the database does if SSL is available or whether it's possible to use client certificates over unix domain sockets. Likely, SSL and domain sockets do not make sense.

@jvz
Copy link

jvz commented Jan 26, 2023

Did you ever decide on a URL syntax for this feature?

@mp911de
Copy link
Collaborator Author

mp911de commented Jan 26, 2023

The format is: r2dbc:postgresql:///foo?socket=/tmp/.s.PGSQL.5432

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants