sphereio / sphere-message-processing

This node.js library is designed to provide an easy way to write a SPHERE.IO message processors.
MIT License
1 stars 1 forks source link

Error during: Locking the message #3

Open CHH opened 9 years ago

CHH commented 9 years ago

I get this error when listening for messages

2015-08-18 13:39:13.228 [ERROR] - processing.processor.notify-delivery-added - Error during: Locking the message. Message: <very long message data>
Cause: Error: getaddrinfo ENOTFOUND api.sphere.io
    at errnoException (dns.js:44:10)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:94:26)

My message processing code:

var {MessageProcessing, LoggerFactory} = require("sphere-message-processing")
var Q = require("q")
var request = require("request")
var crypto = require("crypto")
var querystring = require("querystring")

function processMessage(sourceInfo, msg) {
    console.log(msg.type)
    if (msg.type === "ParcelAddedToDelivery") {
        console.log(sourceInfo)
        console.log(msg)

        var hash = crypto.createHash("sha512")
        hash.update(querystring.stringify(msg))

        var d = Q.defer()

        request.post(argv.baseUrl+"/messages/parcel-added-to-delivery", {
            form: {
                message: msg,
                hash: hash.digest("hex")
            }
        }, (err, httpResponse, body) => {
            console.log("POST result:", err, body)
            if (err) {
                return d.reject(new Error("Failed making POST"))
            } else {
                return d.resolve({processed: true, processingResult: {notifiedShippingEmails: true}})
            }
        })

        return d.promise
    } else {
        return Q({processed: true, processingResult: {ignored: true}})
    }
}

var builder = MessageProcessing.builder()
    .processorName("notify-delivery-added")
    .optimistDemand("baseUrl")
    .optimistExtras((o) => {
        o.describe("baseUrl", "Base URL of the shop environment, e.g. https://pure.testserver2.at/de")
    })
    .messageType("order")
    .build((argv, stats, requestQueue, cc, rootLogger) => {
        var logger = LoggerFactory.getLogger("notify-delivery-added", rootLogger)

        return processMessage
    })

var messageProcessor = builder()
messageProcessor.start()
hajoeichler commented 9 years ago

@CHH looks like a very base level problem as you can't get the address for api.sphere.io. @OlegIlyenko maybe you can have a look if there are some parameters missing please.

OlegIlyenko commented 9 years ago

I would agree with @hajoeichler. Judging on the error message, it looks like a DNS issue. During the quick review, I can see only one issue: argv is not passed down to processMessage function from build function even though it's used there.