Steven Spielberg
Steven Spielberg

Reputation:

connection host failed to respond in C# Mysql

What is means of these error in MySQL

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

There is already an open DataReader associated with this Connection which must be closed first.

Upvotes: 1

Views: 3208

Answers (1)

Steven Spielberg
Steven Spielberg

Reputation:

This error:

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

Means that your command is trying to fetch data from table. The table might have a huge amount of data and it can not respond in the time allowed (which you set as timeout in connection string).

Try the following to solve the issue

  1. Make your queries smaller or divide them into parts if possible.
  2. Increase the command timeout in the connection string on when you open the connection from Mysql server.

There is already an open DataReader associated with this Connection which must be closed first.

It means that your application can open a second connection before the first one closes resulting in an error.

Try any of the following to resolve your issue:

  1. Close the first connection before opening another.
  2. Allow the MySql server to allow multiple connections.
  3. Dispose and close the connection when it's no longer of use.

Upvotes: 4

Related Questions