0
votes

I am invoking API.AI API call in Firebase Cloud function to process a message in response to Firebase childAdded event. However, I am getting the following error message. The API.AI call works fine in a standalone nodeJS app that I ported from.

Error: socket hang up
    at createHangUpError (_http_client.js:254:15)
    at TLSSocket.socketOnEnd (_http_client.js:346:23)
    at emitNone (events.js:91:20)
    at TLSSocket.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:974:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickDomainCallback (internal/process/next_tick.js:122:9)

Any ideas on what could be going wrong here. I am on Firebase Spark plan.

Thanks in advance

1

1 Answers

1
votes

I figured out the issue was nesting the api.ai request.end within api.ai request.on("response" ..) event. By moving it after the api.ai request.end statement the error dissapeared

Initially, I had thought it was an issue with being in Spark plan (a free tier). However, that wasn't the case.