[CONJ-174] [Feature Request] fallback to socket connection if other type requested and fails Created: 2015-07-29  Updated: 2023-12-15  Resolved: 2023-12-15

Status: Closed
Project: MariaDB Connector/J
Component/s: configuration
Affects Version/s: None
Fix Version/s: N/A

Type: Task Priority: Minor
Reporter: Geoffrey Rutherford Assignee: Diego Dupin
Resolution: Won't Do Votes: 0
Labels: None


 Description   

For applications to work across platforms it would be useful to have a preferred connection type and to configure for this but for the protocol to fall back to socket connections if the preferred connection type doesn't work. For example I'd like domain sockets to be used on Unix systems but my software is also used on Windows systems where these aren't available. So my suggestion is to change the create socket code in MySQLProtocol at line 245 to the following:

// Create socket with timeout if required

String stype = null;
String sname = null;
Options opts = jdbcUrl.getOptions ();

try
{
stype = "pipe"; sname = opts.pipe; if (sname != null) socket = new org.mariadb.jdbc.internal.mysql.NamedPipeSocket (host, sname); else {
stype = "localSocket"; sname = opts.localSocket; if (sname != null) socket = new org.mariadb.jdbc.internal.mysql.UnixDomainSocket (sname); else {
stype = "sharedMemory"; sname = opts.sharedMemory; if (sname != null) socket = new SharedMemorySocket (sname);}}
}

catch (Exception e)

{ System.out.println ("Failed to create " + stype + " '" + sname + "' with error: " + e.toString ()); System.out.flush (); }

if (socket == null)

{ socket = socketFactory.createSocket (); }

 Comments   
Comment by Vladislav Vaintroub [ 2016-04-05 ]

The client might end up unexpectedly (for client) connected to wrong server. In many cases people would not want the fallback, but want to be informed that connection is not possible.

I think this request would only make sense, if multiple transports are specified in the same connection URL (if this is possible currently, I do not know)

Comment by Diego Dupin [ 2016-08-24 ]

I think too that would be confusing if done automatically, because how would you know that connection isn't the one initialy indicated !?
Only solution is to have a new option to explicitly indicate to fallback to socket connection.

There is already a lot of options. Would this be interresting enought to add a new options ?

Comment by Diego Dupin [ 2023-12-15 ]

URI in RFC3986 doesn't permit to explicitly set multiple protocol, and without explicit request, we cannot change the default to that kind of behavior, so closing

Generated at Thu Feb 08 03:13:44 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.