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

Fix_for_OrionCB Payload loss #1408

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

KeshavSoni2511
Copy link
Contributor

Fix for issue #1407

@KeshavSoni2511
Copy link
Contributor Author

Gentle Reminder!

@@ -52,7 +52,7 @@ function getOptions(options) {
searchParams: options.searchParams || options.qs,
headers: options.headers,
throwHttpErrors: options.throwHttpErrors || false,
retry: options.retry || 0,
retry: options.retry || 5,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taken into account this retry parameter, I wonder if the loop based in retry_count is really needed. Could you include got library documentation about this retry option, please?

Copy link
Contributor Author

@KeshavSoni2511 KeshavSoni2511 Aug 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @fgalan , I include this retry count to make the default value less than httpOptions.retry so that the agent can retry 5 times before error.

Same here in https://github.com/telefonicaid/iotagent-json/blob/ef782f8f89ea2d0769dc36ecf9d96c63ef82cc17/lib/bindings/AMQPBinding.js#L130
and numRetried is used.

And please reply if I have to code it in camel case

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to https://github.com/sindresorhus/got#documentation

By default, Got will retry on failure. To disable this option, set options.retry.limit to 0.

Thus, I'd say that the only needed modification is to unhardwire the 0 value currently used, so it can be configured (by config.js and env var).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, modifications from L98 to L130 wouldn't be necessary, as far as I understand.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @fgalan , I have changed the default value but the agent was not retrying to connect to orion CB when it was down. Thats why I have to code to make it retry 5 times and also through an error as it was initially doing but after retrying 5 times after a particular interval of time. Thanks for the reply.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean that got library is not working properly? As far as I understand, the got library should deal with this.

https://github.com/sindresorhus/got/blob/main/documentation/7-retry.md shows a pretty sophisticated configuration. I'd suggest to see how it works and use it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @fgalan , I just want to say to make that work we need some value to make it work 5 times so that it comes out of loop after max retries as it is implemented also in

https://github.com/telefonicaid/iotagent-json/blob/ef782f8f89ea2d0769dc36ecf9d96c63ef82cc17/lib/bindings/AMQPBinding.js#L130

and line 145

@mapedraza
Copy link
Collaborator

Did you test yourself if it works? I do not think so... Anyway, a tests verifying this new behaviour, together with the documentation are required.

@mapedraza
Copy link
Collaborator

As @fgalan mentioned, this PR as it is right now is not the best way to implement CB retries, as the got driver implements retry options. The best is to wire those options (right now is disabled)

Some test cases should be implemented, reflecting a failling connection and working after some retries.

This should be configured as per device group, since the CB is also configurable at device group.

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

Successfully merging this pull request may close these issues.

3 participants