Bug #6634 An Open Connection has been Closed by the Host System
Submitted: 15 Nov 2004 12:17 Modified: 10 Dec 2004 20:03
Reporter: Jim Wilson Email Updates:
Status: Closed Impact on me:
Category:Connector / NET Severity:S2 (Serious)
Version: OS:Windows (Windows ?? (2003 - Web Host))
Assigned to: Reggie Burnett CPU Architecture:Any

[15 Nov 2004 12:17] Jim Wilson
My Application will run fine for several hours to several days depending on the traffic to the site.  Then it will start getting an exception that "An Open Connection has been Closed by the Host System" when ever it tries to make a DB Call (Probably the actual open of the connection but your exception does not provide that much detail.)

I have double checked that I am closing all my open connections in the correct way.

How to repeat:

Run the site for many hours with users on it.

Suggested fix:

[15 Nov 2004 15:05] Reggie Burnett
This will be hard to find unless we can find some code that will reproduce it.  We'll keep the bug report open but  you'll need to help us gather as much evidence as possible to try and pinpoint the problem.
[22 Nov 2004 19:27] Tony Perri
I have experienced the same problem.  Here is the stack trace:

[SocketException (0x2745): An established connection was aborted by the software in your host machine]

   System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) +421

   System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size) +102


[IOException: Unable to write data to the transport connection.]

   MySql.Data.MySqlClient.MySqlConnection.Open() +148

   System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState) +44

   System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +304

   System.Data.Common.DbDataAdapter.Fill(DataTable dataTable, IDbCommand command, CommandBehavior behavior) +28

   System.Data.Common.DbDataAdapter.Fill(DataTable dataTable) +88

   FileMover.DAL.MICStats.GetFileList(String[] fileNames) +320

   FileMover.BLL.Archive.GetFiles(String instId, DateTime date) +270

   FileMover.Requeue.uiListFilesButton_Click(Object sender, EventArgs e) +76

   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108

   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57

   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18

   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33

   System.Web.UI.Page.ProcessRequestMain() +1292
[23 Nov 2004 20:21] Tony Perri
I am able to reproduce this by running a query, stopping and restarting the mysql service, and then running the query again.  The workaround seems to be adding pooling=false to the connection string.  I'm not sure what this will do to performance.
[30 Nov 2004 19:54] [ name withheld ]
I am consistently running into this issue as well with an asp.net application (and .Net Connector 1.0.2). I will try setting pooling=false to see if that resolves the problem temporarily.
[1 Dec 2004 9:30] Moreno Gentili
Same problem here.
I have a new server with win2000 and I tried running the an aspx page over and over (a javascript reloads it every 2 seconds). This page executes a very simple query "SELECT id FROM test" on table with 1 column and 1 row. After several hours (6 to 8 hours) I get that error and I cannot do anything else than restarting IIS to get that back to work. I'll try the pooling=false option
[7 Dec 2004 0:37] Chris Sigrist
Based on another comment from the forums, this issue (which occurs for me too) might be related to a firewall severing an open mysql connection.  When the site tries to reuse an open connection (which the firewall has severed) it throws an exception.  This may be why the problem occurs only after a certain amount of time has passed.
[10 Dec 2004 17:42] Mark Frisbee
I am having the same problem. To reproduce it, create a method that creates a connection, opens the connection, closes the connection, and disposes the connection. Run this method and then use MySQL Administrator to kill the newly created thread. Next call this method again and the error will occur. As Chris Sigrist pointed out, if Pooling is set to false the error will not occur.
[10 Dec 2004 20:03] Reggie Burnett
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at

Additional info:

A fix for this has been committed.
[18 Jan 2005 3:51] Matthew Bilek
I am consistently receiving the following error:
InnerException = "An existing connection was forcibly closed by the remote host" 
Message = "Unable to write data to the transport connection."

I can consistently recreate this problem, though it will occur at different rows in the table.
I am attempting to save binary data in a MEDIUMBLOB column.
My connection string does contain “pooling=false”.

Any ideas what may be causing this?
[5 Apr 2005 12:44] Scott Lane
I have the same problem. I didn't have it until I changed the table's character set from ASCII/LATIN1 to UTF8. Once I did that, the table with the LARGETEXT columns would allow data to be inserted for a while and then stop loading altogether with the "Unable to write data to the transport connection" message. I am going to revert back to LATIN1 character set and see if the problem goes away.
[21 Oct 2005 20:17] Lon Palmer
This bug is not fixed.  I'm still getting the same behavior:
1) Doing many inserts of largblob on a table will induce this bug after the first 100 or so inserts.

MySQL Server 4.1
MySQL Connector/Net 1.0.6

The Status should be changed to OPEN!
[14 Nov 2005 9:16] Oscar Acosta
I'm having the same problem, I can't even run the example project included with connector. In a Win2k Sp4, .Net 1.1, MySql 5.0, and VisualStudio 2003. I'm not using pool or anything else. Please, help. Thanks.
[16 Mar 2006 16:13] Lee Phillips
I am getting a very similar problem that I think may have the same roots.  I am using v4.0.26 of MySQL and v1.0.7 of the .Net connector and VS2003 using C# for development.  We don't have any BLOB fields in our database,  but in testing we get the the "Connection forcibly closed" message regularly, particularly if we have a VPN client running on the computer running the application that hits the MySQL database.  The problem is serious enough that we're taking a hard look at shutting down the project and switching to a different platform.
[23 Mar 2010 7:14] Mo Heaven
Was this ever solved? I am having this seem problem and i need help please.

mysql connector 6.05
vs 2008
mysql v. 5.1.45

[6 Dec 2012 11:13] Surupa Dutta
I am also getting "closed MySQL connection" error while uploading a file of size 466.6 KB with 290 images. I am extracting images and converting them to increase the density of them.
Please help..
[31 Mar 2020 23:00] Isa Tahiri
So many years and still not corrected. I also have this error from my ASP.net application. 

Anyone has found a solution ?
[31 Mar 2020 23:01] Isa Tahiri
So many years and still not corrected. I also have this error from my ASP.net application. 

Anyone has found a solution ?