4 messages in com.mysql.lists.dotnetRe: Error: "An existing connection wa...
FromSent OnAttachments
SGr...@unimin.com21 Apr 2005 09:16 
Reggie Burnett21 Apr 2005 09:29 
David Travis21 Apr 2005 09:53 
David Travis25 Apr 2005 15:34 
Subject:Re: Error: "An existing connection was forcibly closed by the remote host"
From:SGr...@unimin.com (SGr@unimin.com)
Date:04/21/2005 09:16:15 AM
List:com.mysql.lists.dotnet

"David Travis" <dav@macam.ac.il> wrote on 04/21/2005 12:53:24 PM:

Hi All,

I am using latest connector (1.0.4), mysql version is 4.1.10a-nt. InnoDB, UTF8.

When I try to insert into a blob field a binary stream of a file larger than 1 mega in a ASP.NET site I get the following error. I read in some places that this is a bug in the database, but I wanted to make sure this is the case.

The code is very simple, a MySqlParameter with blob type, which accepts the posted file as a value and added to the parameterized query.

Thanks in advance,

Here is the full error page:

<snip>

One megabyte is the default size of a server parameter: max_alowed_packet.(http://dev.mysql.com/doc/mysql/en/dynamic-system-variables.html) If for some reason you cannot compose a complete statement within that limit, the server thinks that there is a problem with the connection and drops it ("forcibly closes" it to use the term you see in your error message)

What you can do to help the server to not choke on your BLOB is to tell it to expect a larger packet by using the SET command (http://dev.mysql.com/doc/mysql/en/set-option.html) to update the size of the max_allowed_packet variable so that it's large enough to handle the BLOB you are trying to send. I would bet that you won't have rights to affect the inbound packet size for the entire server (SET GLOBAL) so I would try

SET SESSION max_allowed_packet=###### (whatever you actually need)

Send it on the connection as an SQL command and don't close the connection until the BLOB has been sent. Sorry, I don't DB with .NET (but I do with ADO) or I could give you an actual command to try.

Shawn Green Database Administrator Unimin Corporation - Spruce Pine