title: Expected to read 4 header bytes but only received 0
body: <p>I have written a windows service which uses SSH (Secure Shell) to copy data from a CSV file to PhpMyAdmin online database.</p>
  
  <p>There was an error trigger when the connection opens,</p>
  
  <pre><code>MySql.Data.MySqlClient.MySqlProtocolException
    HResult=0x80131509
    Message=Packet received out-of-order. Expected 2; got 1.
    Source=mscorlib
    StackTrace:
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
  </code></pre>
  
  <p>As a solution, I decided to hold the current thread and add the following line before the connection opens.</p>
  
  <pre><code>Task.Delay(TimeSpan.FromMilliseconds(10000)).Wait();
  </code></pre>
  
  <p>Unfortunately, that leads to an another error,</p>
  
  <pre><code>MySql.Data.MySqlClient.MySqlException
    HResult=0x80004005
    Message=Failed to read the result set.
    Source=MySqlConnector
    StackTrace:
  Inner Exception 1:
  EndOfStreamException: Expected to read 4 header bytes but only received 0.
  </code></pre>
  
  <p>When I randomly changed the value of the time the thread holds, the above 2 errors varies with each other.</p>
  
  <p>Related code chunk:</p>
  
  <pre><code>        Public  void insert(string connString){
          using (var conn = new MySqlConnection(connString))
          {
  
               Task.Delay(TimeSpan.FromMilliseconds(10000)).Wait();
                  conn.Open();
              using(var reader = new StreamReader(@"C:\Users\Admin\source\Bargstedt.csv"))
              {
                  while (!reader.EndOfStream)
                  {
                      var line = reader.ReadLine();
                      var values = line.Split(',');
                      string querynew = "INSERT INTO jobs"
                                  + "(nJobNumber,strClientReference,datPromisedDelivery)" 
                                  + "VALUES (@jobNo, @strClientName, @strClientReference)";
  
                      using (var cmd = new MySqlCommand())
                      {
  
                          cmd.Connection = conn;
                          cmd.CommandText= querynew;
                          cmd.Parameters.AddWithValue("jobNo", values[0]);
                          cmd.Parameters.AddWithValue("strClientName", values[1]);
  
  
                          cmd.Parameters.AddWithValue("strClientReference",values[2]);
  
  
                          cmd.ExecuteNonQuery();
                      }
                  }
              }
          }
      }
  </code></pre>
  
  <p>Any suggestions how to fix this exception?</p>