Bug #6634 An Open Connection has been Closed by the Host System
Submitted: 15 Nov 2004 13:17 Modified: 10 Dec 2004 21:03
Reporter: Jim Wilson
Status: Closed
Category:Connector/Net Severity:S2 (Serious)
Version:1.0.1.12619 OS:Microsoft Windows (Windows ?? (2003 - Web Host))
Assigned to: Reggie Burnett Target Version:

[15 Nov 2004 13:17] Jim Wilson
Description:
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 16: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 20: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(St
ring 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 21: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 20: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 10: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
bye
[7 Dec 2004 1: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 18: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 21: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
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

A fix for this has been committed.
[18 Jan 2005 4:51] Matthew Bilek
I am consistently receiving the following error:
System.IO.IOException
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 14: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 22: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 10: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 17: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.