Peppe Nanna

Peppe Nanna

  • NA
  • 6
  • 618

Unhandled exception. A transport-level error occurred.....

Dec 4 2022 3:26 PM

Hello friends. Let share with you an issue I am facing today.

I have an application that reads the state of a machinery each 5 seconds.
The machinery write its state in a MSSQL database.

public async void getstate()
{
    SqlConnection conn = new SqlConnection("Server=sql11.hostinguk.net;Database=mydatabase;User Id=myuser;Password=mypwd;MultipleActiveResultSets=True;");
    
    conn.Open();

 using (SqlCommand cmd = new SqlCommand("SELECT state FROM [mydbo] WHERE id='1', conn))
    { 
        SqlDataReader sqlreader = cmd.ExecuteReader();

        while (sqlreader.Read())
        {
            .......

        }

        sqlreader.Close();

   }

   conn.Close();

    await Task.Delay(5000);

    callGetState();  

}

public void callGetState()
{
    getstate();
}

The issue is that after some hours I get: "Unhandled exception. A transport-level error occurred while receiving results from the server. (provider: Session Provider, error: 19 - Could not use physical connection)."

I don't know how to solve it.
Any help will be very appreciated.

 


Answers (1)