Skip to content

Commit

Permalink
adjust error handling for spm-receiver status codes
Browse files Browse the repository at this point in the history
  • Loading branch information
megastef committed Aug 13, 2018
1 parent 02e20a7 commit f38a0b7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/sender/spmsender.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ SpmSender.prototype.retransmit = function (metrics, callback) {
return m._id
})
var req = request.post(options[xi], function (err, res, body) {
if ((!err) && (res && res.statusCode < 300)) {
if ((!err) && (res && (res.statusCode < 300 || (res.statusCode >= 400 && res.statusCode < 500)))) {
// remove from NeDB
db.remove({_id: {$in: dpIds}}, {multi: true}, function (err, numRemoved) {
dpIds = null
Expand Down Expand Up @@ -533,7 +533,9 @@ function getResponseHandler (dpCount, url, self, callback) {
return function (err, res, body) {
try {
var msg = ''
if (err || (res && res.statusCode > 299)) {
if ((res && res.statusCode > 499) || err) {
// err could be DNS problem or TCP timeout
// Status code 400 might be caused by deactivated tokens -> no retry
msg = util.format('HTTP Error: %d send failed for %d data points to %s, %s', (res ? res.statusCode : -1), dpCount, url, body || err)
if (!err) {
err = {}
Expand Down

0 comments on commit f38a0b7

Please sign in to comment.