Error when sending Push Notification via Cloud Function


#1

Hey Expo team,

First of all, thank you for all that you have created. It is truly awesome!

I am still getting acquinted with it, and I am having a problem sending a POST request to your Push Notification server from my cloud function.

This is the code I am currently using (with request library for JS):


    expoPushURL = "https://exp.host/--/api/v2/push/send";

    headers = {
        "accept": "application/json", 
        "accept-encoding": "gzip, deflate", 
        "content-type": "application/json"
    };

    data = JSON.stringify({
        "to": "ExponentPushToken[myDeviceToken]", 
        "sound": "default", 
        "title": "hello", 
        "body": "Hello world!"
    });

    options = {
        url: expoPushURL, 
        headers: headers, 
        method: "POST", 
        body: data, 
        json: true
    };
    request(options, function (error, response, body) {
        console.log("Response from request: ",response);
        console.log("Error from request: ", error); 

    });

This is the error that I am getting:

Error from request:  { Error: getaddrinfo ENOTFOUND exp.host exp.host:443
    at errnoException (dns.js:28:10)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)
  code: 'ENOTFOUND',
  errno: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'exp.host',
  host: 'exp.host',
  port: 443 }

Any ideas how I can resolve it?

Much thanks,

Matt


#2

{ Error: getaddrinfo ENOTFOUND exp.host exp.host:443

Sounds like this might have been a transient networking error. Can you try again and let us know if it works?


#3

Thank you for the quick response, ccheever.

I have tried again and it is giving me the same error.


#4

Hmmm… I think this may have been related to an incident we had yesterday with our servers. More info here: https://status.expo.io/ Let me know if youi’re still seeing the issue. So sorry about that.


closed #5

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.