Bug #69289 Getting the error “A socket operation was attempted to an unreachable network”
Submitted: 20 May 2013 17:05 Modified: 14 Jun 2016 12:54
Reporter: Zaheer Sheikh Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / NET Severity:S1 (Critical)
Version:6.6.5 OS:Windows (2008 R2 64 bit)
Assigned to: CPU Architecture:Any
Tags: ASP.NET 4.0, MySql Connector, Windows 2008

[20 May 2013 17:05] Zaheer Sheikh
Description:
I am getting the error "A socket operation was attempted to an unreachable network" inconsistently in ASP.NET 4.0 Web App only when Web App is hosted on "Windows Server 2008 R2 SP1 - 64-bit" machine. My Web App uses:

Visual Studio 2010
ASP.NET 4.0
Entity Framework
MySql Server 5.0
MySql Connector 6.6.5

The same App works well on "Windows Server 2003 R2 - 64-bit" machine. Please suggest some solution to this. Be noted that, it is able to connect to MySql but It's connection behavior is flaky i.e. it breaks with the said error randomly but not always.

How to repeat:
1. Create a web app in ASP.NET 4.0 using Visual Studio 2010.
2. Add Entity Model from database in MySql Server (InnoDB) hosted on Linux server.
3. Write a code to connect database & fire select query.
4. Compile it publish it on a windows 2008 server R2 64-bit. it should break in to following error:

"A socket operation was attempted to an unreachable network" 

inconsistently.
[20 May 2013 23:03] Roberto Ezequiel Garcia Ballesteros
Hi,

Please take a look into this <a href="http://forums.mysql.com/read.php?38,578677,578712#msg-578712">post</a>.

It could be a TCP issue on Windows or due to the high traffic volume.

This other <a href="http://support.microsoft.com/kb/2553549">post</a> talks about other possible issue.

Please let me know if these works for your problem.

Regards.
[24 May 2013 9:09] Zaheer Sheikh
Thanks Roberto for your reply & suggestion.

I applied the solutions suggested in the links but it did not resolve the issue.
The tcp port "start & num" has been updated but still it did not resolve the issue.

Thanks,
Zaheer
[27 May 2013 8:25] Zaheer Sheikh
In addition to the above info, Please be notified that the website hosted on the same server works well with "MS SQL Server 2008 R2" hosted on a different Database Server.
 The TCP server/ports does not create any problem with "MS SQL Server 2008 R2" but  when it tries to connect MySql Server through "MySql Connector 6.6.5", it gives the above message that has the correct port# 3306 but some non-existing IP like 0.0.12.234:3306.

Please revert with some solution to this as the website is required to go live very soon.

Thanks,
Zaheer
[1 Jun 2013 16:31] Zaheer Sheikh
It's been a long time waiting for the response from the "MySql Forum" so I tried "Devart's MySql Connector" with the same application and it worked fine. It proved to me that "MySql Connector/Net" is having some bug in it that caused the problem concerned.

I would prefer to use "MySql Connector/Net" if the "MySql Connector/Net" Team can resolve this issue.

Please keep me updated on this.

Thanks,

Zaheer
[25 Feb 2014 22:46] Zach Pellman
I know this is almost a year old now, but I recently came across this bug report while troubleshooting the exact same problem (though on an older version of the connector, 6.5.5).

The "solution" turned out to not be a problem with the MySQL connector for .NET, but with the connection string I was using for the MySQL database.

I had written my connection string as 'Server="a.b.c.d,3306"', the way I would for a MSSQL connection string, not realizing that what I needed to write was 'Server="a.b.c.d";Port="3306"', and was seeing the same error where it failed to connect to 0.0.12.234.

It turns out if you convert the IP address 0.0.12.234 to a number, you get 3306. The MySQL connector treats the Server string as a comma-separated list of hosts, so where I intended to specify a port, the connector treated it as another host and converted the number to an IP address. Furthermore, the connector tries to connect to each host in a random order, leading to the issue occurring only intermittently.

Hopefully this helps resolve the issue.
[14 Jun 2016 12:54] Chiranjeevi Battula
Hello Zaheer Sheikh,

Thank you for your feedback.
I could not repeat the issue at our end using with Visual Studio 2013(Asp.Net), Connector/NET 6.9.8 but not seeing any issues in connections.
If you can provide more information, feel free to add it to this bug and change the status back to 'Open'.

Thank you for your interest in MySQL.

Thanks,
Chiranjeevi.