Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retry sync client calls with usual errors #661

Open
bitomaxsp opened this issue Jun 9, 2023 · 2 comments
Open

Retry sync client calls with usual errors #661

bitomaxsp opened this issue Jun 9, 2023 · 2 comments

Comments

@bitomaxsp
Copy link
Contributor

bitomaxsp commented Jun 9, 2023

Problem: monitor loop handles reconnects and session reestablishing gracefully depending on the result of the last operation.
But syn call result (error in this case) is also propagated back to the caller (which is user of the library who calls sync methods). Some of those errors could be retried internally and user request could be resend.

Usual suspects that we at Northvolt retry are:

func readErrorProc(err error) bool {
	switch {
	case errors.Is(err, io.EOF): // connection closed by server
		return true

	case errors.Is(err, ua.StatusBadSecureChannelIDInvalid): // secure channel is renewing
		return true

	case errors.Is(err, ua.StatusBadSessionNotActivated):
		return true

	case errors.Is(err, ua.StatusBadSessionIDInvalid):
		return true

	case errors.Is(err, ua.StatusBadServerNotConnected):
		return true

	case errors.Is(err, ua.StatusBadTimeout):
		return true
	}

	return false
}

For us it is dramatically improved stability of the application working over OPCUA.

Going forward we could probably have configurable retry logic for synchronous client calls. Wdyt @magiconair and @kung-foo ?

@sruehl
Copy link
Contributor

sruehl commented Aug 16, 2023

Not sure, but this might be a related issue: #239

@sruehl
Copy link
Contributor

sruehl commented Aug 16, 2023

Just as an option because it has a really simple API: https://github.com/avast/retry-go

So the code samples from OP above can be nicely combined with that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants