modbus icon indicating copy to clipboard operation
modbus copied to clipboard

EOF panic modbus tcp-client.

Open mosleim opened this issue 6 years ago • 1 comments

i just create simple mobdus tcp-client(modbus master). Everythings works perfectly. But, some of condition, my program panic triggeren and closed. this is my piece of code:

			data, err := client.ReadHoldingRegisters(41201, 100)
			if err != nil {
				fmt.Println("e1:", err)
				if strings.Contains(err.Error(), "tcp") {
					break
				}
			}

simple and this code is buggy. my program always panic and closed when the ethernet wire is disconnected(accidentally). the error caused by EOF. how to detect EOF and i can reconnect if possible?

mosleim avatar Oct 05 '18 19:10 mosleim

i just create simple mobdus tcp-client(modbus master). Everythings works perfectly. But, some of condition, my program panic triggeren and closed. this is my piece of code:

			data, err := client.ReadHoldingRegisters(41201, 100)
			if err != nil {
				fmt.Println("e1:", err)
				if strings.Contains(err.Error(), "tcp") {
					break
				}
			}

simple and this code is buggy. my program always panic and closed when the ethernet wire is disconnected(accidentally). the error caused by EOF. how to detect EOF and i can reconnect if possible?

I encountered the same problem. Has your problem been solved?

hongjinlin avatar Mar 10 '21 01:03 hongjinlin