Bug #61042 | Can not connect to mySQL server from windows CE using .NET connector | ||
---|---|---|---|
Submitted: | 3 May 2011 16:38 | Modified: | 3 Sep 2011 0:57 |
Reporter: | Peter Micuch | Email Updates: | |
Status: | No Feedback | Impact on me: | |
Category: | Connector / NET | Severity: | S1 (Critical) |
Version: | 6.2.4 (any) | OS: | Windows (Win Server 2008) |
Assigned to: | Assigned Account | CPU Architecture: | Any |
Tags: | Compact Framework, Unable to connect, unresolved IP address, widnows CE |
[3 May 2011 16:38]
Peter Micuch
[4 May 2011 9:36]
Peter Micuch
I have had today a debug session on the system again. When my device is trying to connect to MySQL server running on the server A it gets into the method StreamCreator.GetStream(uint timeout) where I found this code snippet: IPHostEntry ipHE = GetHostEntry(dnsHosts[index]); foreach (IPAddress address in ipHE.AddressList) { // MySQL doesn't currently support IPv6 addresses if (address.AddressFamily == AddressFamily.InterNetworkV6) continue; stream = CreateSocketStream(address, false); if (stream != null) break; } The problem is, that ipHE.AddressList contains all 3 addresses of the server in this order: 199.199.100.3, 213.81.x.x, 192.168.99.7. So the actual address that was used in the connection string (192.168.99.7) is at the last place. When I skipped first two addresses in the foreach loop, the connection was established! Why is not the IP address that was used in the connection string used in the first place? Please have a look to this issue and if possible, provide fix in the next release.
[5 May 2011 15:51]
Peter Micuch
As a temporary fix I modified the method ParseIPAddress so that it actually tries to parse given IP address also in case of running in compact framework environment. Since in my case I do not expect to get anything else than real IP address it is OK to use the "try catch" approach, but should be reconsidered for other environments. private IPHostEntry ParseIPAddress(string hostname) { IPHostEntry ipHE = null; IPAddress addr; #if !CF if (IPAddress.TryParse(hostname, out addr)) { #else try { addr = IPAddress.Parse(hostname); #endif ipHE = new IPHostEntry(); ipHE.AddressList = new IPAddress[1]; ipHE.AddressList[0] = addr; } #if CF catch(FormatException) { //Host name is not a valid IP address, kindly return null } #endif return ipHE; }
[6 May 2011 8:25]
Peter Micuch
I change the version to 6.2.4 as this concerns Connector version and not version of MySQL server itself. I also changed Severity to critical, since this problem will be visible to everyone that is using MySQL on the server with multiple network cards (multiple IP addresses).
[13 May 2011 14:48]
Valeriy Kravchuk
Please, check if this problem happens with a newer version of Connector/Net, 6.3.6 or 6.4.0.
[18 May 2011 12:27]
Peter Micuch
While installing 6.3.6 on Win7 I get an error and the installer exits. But if the code of the problematic method haven't changed since older version, I guess the problem will as well be visible in 6.3.6.
[31 May 2011 20:41]
Julio Casal
Please provide a small sample Visual Studio project where this problem is easily reproduced so that I can take a look at it and work on a solution.
[1 Jul 2011 23:00]
Bugs System
No feedback was provided for this bug for over a month, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open".
[3 Sep 2011 23:00]
Bugs System
No feedback was provided for this bug for over a month, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open".