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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- Upgrade mongoose dep from 5.13.14 to 5.13.20
- Fix: Payload measures are lost after reconnection with Orion (#1407)
- Upgrade mongoose dep from 5.13.14 to 5.13.20
4 changes: 3 additions & 1 deletion config.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ var config = {
subservice: '/gardens',
providerUrl: 'http://192.168.56.1:4041',
deviceRegistrationDuration: 'P1M',
defaultType: 'Thing'
defaultType: 'Thing',
ORION_DEFAULT_RETRIES: 5,
ORION_DEFAULT_RETRY_TIME: 5
};

module.exports = config;
24 changes: 12 additions & 12 deletions doc/deprecated.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ information in the case you want to use old versions:

The following table provides information about the last iotagent-node-lib version supporting currently removed features:

| **Removed feature** | **Last iotagent-node-lib version supporting feature** | **That version release date** |
| ---------------------- | ----------------------------------------------------- | ----------------------------- |
| NGSI v1 API | 2.17.0 | August 30th, 2021 |
| Support to Node.js v4 | 2.8.1 | December 19th, 2018 |
| Support to Node.js v6 | 2.9.0 | May 22nd, 2019 |
| Support to Node.js v8 | 2.12.0 | April 7th, 2020 |
| Support to Node.js v10 | 2.15.0 | February 18th, 2021 |
| Support to Node.js v12 | 2.24.0 | September 2nd, 2022 |
| Support to NGSI-LD 1.3 | 2.25.0 | January 24th, 2023 |
| Support to Legacy Expressions | 3.1.0 | April 25th, 2023 |
| bidirrectional plugin | 3.3.0 | August 24th, 2023 |
| appendMode | 3.3.0 | August 24th, 2023 |
| **Removed feature** | **Last iotagent-node-lib version supporting feature** | **That version release date** |
| ----------------------------- | ----------------------------------------------------- | ----------------------------- |
| NGSI v1 API | 2.17.0 | August 30th, 2021 |
| Support to Node.js v4 | 2.8.1 | December 19th, 2018 |
| Support to Node.js v6 | 2.9.0 | May 22nd, 2019 |
| Support to Node.js v8 | 2.12.0 | April 7th, 2020 |
| Support to Node.js v10 | 2.15.0 | February 18th, 2021 |
| Support to Node.js v12 | 2.24.0 | September 2nd, 2022 |
| Support to NGSI-LD 1.3 | 2.25.0 | January 24th, 2023 |
| Support to Legacy Expressions | 3.1.0 | April 25th, 2023 |
| bidirrectional plugin | 3.3.0 | August 24th, 2023 |
| appendMode | 3.3.0 | August 24th, 2023 |
25 changes: 22 additions & 3 deletions lib/request-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* For those usages not covered by the GNU Affero General Public License
* please contact with::[email protected]
*/

const config = require('../config');
const got = require('got');
const logger = require('logops');
const context = {
Expand Down Expand Up @@ -95,17 +95,36 @@ function getOptions(options) {
*
*/

let retryCount = 0; //default retry_count value
function request(options, callback) {
const retryTime = config.ORION_DEFAULT_RETRY_TIME;
const retries = config.ORION_DEFAULT_RETRIES;
const httpOptions = getOptions(options);
logger.debug(context, 'Options: %s', JSON.stringify(options, null, 4));
got(options.url || options.uri, httpOptions)
.then((response) => {
logger.debug(context, 'Response %s', JSON.stringify(response.body, null, 4));
retryCount = 0;
return callback(null, response, response.body);
})
.catch((error) => {
logger.debug(context, 'Error: %s', JSON.stringify(util.inspect(error), null, 4));
return callback(error);
if (error.code === 'ECONNREFUSED') {
if (retryCount < retries) {
retryCount++;
console.log('Retrying connection', JSON.stringify(retryCount));
return setTimeout(request, retryTime * 1000 , options, callback);
}
//retrun the error
else {
retryCount = 0;
logger.debug(context, 'Error: %s', JSON.stringify(util.inspect(error), null, 4));
return callback(error);
}
}
else{
logger.debug(context, 'Error: %s', JSON.stringify(util.inspect(error), null, 4));
return callback(error);
}
});
}

Expand Down