Bug #84255 not work with unix socket
Submitted: 19 Dec 2016 6:30 Modified: 10 Aug 2022 18:40
Reporter: Billy Pang Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / NET Severity:S1 (Critical)
Version:v6.9.9.0 OS:CentOS (CentOS7 x64 with Mono 4.6.2.7)
Assigned to: CPU Architecture:Any
Tags: linux, Mono, sock, unix, unix socket

[19 Dec 2016 6:30] Billy Pang
Description:
I created MySqlConnection with Connection String "server=/var/run/mysql.sock; uid=root; pwd=123456; database=test;", owner/mode of file "/var/run/mysql.sock" are the same as mono process/0777.
When I started the mono process, I got an exception "Could not resolve host '/var/run/mysql.sock'".

How to repeat:
1. Start mysql service with '/var/run/mysql.sock'

2. Create a project with below code, and run via mono under linux:
(new MySqlConnection("server=/var/run/mysql.sock; uid=root; pwd=123456; database=test")).Open()

3. And then will get the exception: Could not resolve host '/var/run/mysql.sock'

Suggested fix:
1. Although the protocol is 'unix', and server is full path of unix socket file, the function 'MyNetworkStream.CreateStream' still try to resolve host ip.

2. The server of Connection String is full path of unix socket file, but the constructor of class 'MySqlConnectionStringBuilder' will not set the protocol to 'unix' automatically.
[20 Dec 2016 6:02] Billy Pang
Actually, the connection string is "protocol=unix; server=/var/run/mysql.sock; uid=root; pwd=123456; database=test;". I wrote it wrong when I was writing!
[11 Jan 2017 6:33] Chiranjeevi Battula
Hello Billy Pang,

Thank you for the bug report.
Please try with Connector/NET 6.10.0 Development Releases version?
Could you please provide repeatable test case (exact steps - please make it as private if you prefer) to confirm this issue at our end?

Thanks,
Chiranjeevi.
[8 Feb 2017 8:11] Billy Pang
see line 8th

Attachment: MyNetworkStream.cs (text/plain), 447 bytes.

[8 Feb 2017 8:12] Billy Pang
I've tried with Connector/NET 6.10.0 Development Releases version, but the function 'MyNetworkStream.CreateStream' still try to resolve host ip, when the protocol is 'unix'
I think it's not necessary to provide repeatable test case, because the source code tells us: It'll try to resolve host ip no matter what protocol you are using!

See the file above.
[20 Feb 2017 7:32] Chiranjeevi Battula
Hello Billy Pang,

Thank you for the feedback.
We could not see any protocol parameter in your connection string, Please use protocol parameter and also make sure to have the Mono.Posix
for your reference use Bug #56410.

Thanks,
Chiranjeevi.
[13 Mar 2017 3:29] Billy Pang
I compiled asp.net application via VS2015, and then ran via Mono.

Here's the server information:
Version Information: 4.8.0 (Stable 4.8.0.495/e4a3cf3 Wed Feb 22 18:07:20 UTC 2017); ASP.NET Version: 4.0.30319.42000

Here's the result of "find / -name Mono.Posix.dll":
/usr/lib/mono/gac/Mono.Posix/4.0.0.0__0738eb9f132ed756/Mono.Posix.dll
/usr/lib/mono/4.5/Mono.Posix.dll
[19 Dec 2017 6:31] Chiranjeevi Battula
Hello Billy Pang,

Thank you for the feedback.
Verified based on internal discussion with dev's.

Thanks,
Chiranjeevi.
[10 Aug 2022 18:40] Daniel Valdez
This is no longer a bug. Please use our latest release, Connector/NET 8.0.30.