Sharp7 icon indicating copy to clipboard operation
Sharp7 copied to clipboard

Sometimes takes 5-10 trials get a stable connection

Open lio94 opened this issue 6 months ago • 2 comments

I notice it sometimes takes 5-10 tries to establish connection, returning different errors, mostly "CLI: Client not connected". This seems happen more likely on the S7-300s and when my application has been closed and restarted (works fine after a complete reboot of the computer).

Task.Factory.StartNew(() => {
  int err = client.ConnectTo(IPAddress, Rack, Slot);
  if (err == 0)
  {
      Connected = client.Connected;
      client.ReadArea(S7Area.DB, InputDB, 0, InputDBSize, S7WordLength.Byte, InputDBBuffer);
  }
  else
  {
      Connected = false;
  }

I was wondering if this is somehow related to not properly handling Sockets and their connection status? #4

Is there an established pattern/guideline on how to bind the connection, and what all possible error checks should be incorporated?

lio94 avatar Jul 25 '24 07:07 lio94