rossmann-engineering / EasyModbusTCP.NET

Modbus TCP, Modbus UDP and Modbus RTU client/server library for .NET implementations
928 stars 402 forks source link

best way to handle this error: Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host. #26

Open theladyjaye opened 5 years ago

theladyjaye commented 5 years ago

I frequently see this error when running either the example GUI apps in this repo or from my own application.

Currently, when I get it, I cleanup my client and reconnect. But I'm curious if this is the best way to handle this.

It seems like it only happens when I wait about 10 seconds with no I/O on the client.

bergi9 commented 5 years ago

Same applies to me. I even check client.Connected before I use client.WriteMultipleCoils(0, values); and the error still appears.

theladyjaye commented 5 years ago

I also get this occasionally:

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.

My device is connected directly to the machine I'm reading it from so it's odd that it's running into this issue.