I'm utilizing tokio-modbus with tokio-retry to do exponential backoff on a tcp-based modbus connection.
This connection can be inconsistent and the tcp stream can fail. When this happens, I get an indication in the form of an Err() that I can parse to figure out that we've lost the tcp stream entirely.
My question: What's the best practice on disconnecting and reconnecting to the same socketaddr/slave_id that was being used in the context prior to a disconnect? I'm trying to do a ctx.disconnect() followed by creating a new ctx object with a fresh connection via tcp::connect_slave() call but I'm wondering if there's a better/more expected way to handle this scenario?
I'm utilizing tokio-modbus with tokio-retry to do exponential backoff on a tcp-based modbus connection.
This connection can be inconsistent and the tcp stream can fail. When this happens, I get an indication in the form of an Err() that I can parse to figure out that we've lost the tcp stream entirely.
My question: What's the best practice on disconnecting and reconnecting to the same socketaddr/slave_id that was being used in the context prior to a disconnect? I'm trying to do a ctx.disconnect() followed by creating a new ctx object with a fresh connection via tcp::connect_slave() call but I'm wondering if there's a better/more expected way to handle this scenario?