Skip to content

Add Pool object for managing sessions (retries, reconnections, etc) #95

Description

@guo1017138

This is not an issue, but I suggest to enhance it for rainy day case.

Problem Description:

  1. started a netconf client normally, make sure it works.
  2. restart netconf server to simulate server restart / network issue.
  3. 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")
	}
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions