-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
This is not an issue, but I suggest to enhance it for rainy day case.
Problem Description:
- started a netconf client normally, make sure it works.
- restart netconf server to simulate server restart / network issue.
- clients won't work again.
Workaround:
I can detect it by the following code sample. But I need to detect several errors as following per my expierence(maybe not all, just what I found). If this lib can support autoconnect feature such like Rockwell AB PLC or just make returned error to be simple will be better.
func (c *Client) checkNetworkError(err error) {
if err == nil {
return
}
_, ok := err.(net.Error)
if ok ||
strings.Contains(err.Error(), "connection closed unexpectedly") ||
strings.Contains(err.Error(), "EOF") ||
strings.Contains(err.Error(), "existing message writer still open") {
c.Logger.Error("network error, reconnecting...")
err = c.reconnect()
if err != nil {
c.Logger.Errorf("reconnect failed: %v", err)
return
}
c.Logger.Info("reconnect success")
}
}Metadata
Metadata
Assignees
Labels
No labels