ECONNREFUSED error when sending push notifications

I’m using Expo to send push notifications with my node.js server as described in https://docs.expo.io/versions/latest/guides/push-notifications/

I keep getting this kind of error :

FetchError: request to https://exp.host/--/api/v2/push/getReceipts failed, reason: connect ECONNREFUSED 104.197.216.164:443

and this as well :

FetchError: request to https://exp.host/--/api/v2/push/send failed, reason: connect ECONNREFUSED 104.197.216.164:443

Is it simply the expo infrastructure failing? Or is my request being rejected for some reason?

I also get this error very frequently:

Error: Expo responded with an error with status code 504: <html>
<head><title>504 Gateway Time-out</title></head>
<body>
<center><h1>504 Gateway Time-out</h1></center>
<hr><center>openresty/1.15.8.2</center>
</body>
</html>

This error normally means that the software on the remote server is not listening on the port you’re trying to connect to. e.g. it crashed and has not yet been restarted. If this is the case it would mean that it is not your specific request that is being rejected.

There’s also a possibility that there’s something in between you and the server that is interfering with the traffic. Either a transparent proxy server or a firewall. This seems less likely to me.

The “Gateway Time-out” error indicates a proxy of some kind, but it could be on Expo’s servers rather than between you and Expo’s servers.

I have not yet needed push notifications, so I haven’t experienced this myself, but I haven’t noticed others complaining about the same thing on the forums, so I’m not sure how common this is.
Is there any pattern to the errors? Certain times of day when they are more likely? What percentage of times do you get the errors? If it fails, how long is it until it starts working again?

Either way it seems best to queue up the notifications and retry them if they fail.

1 Like

Hello,

Randomly I have similar issue. The recent one is happening right now Monosnap, with a response in body Monosnap :

<html>
<head><title>504 Gateway Time-out</title></head>
<body>
<center><h1>504 Gateway Time-out</h1></center>
<hr><center>openresty/1.15.8.2</center>
</body></html>
1 Like

We’re getting this too. Nothing mentioned on status.expo.io :confused:

Someone else got a 503 error rather than a 504 error, but they might both have the same cause. See this message from one of the Expo team members:

Hi we are getting this error too. We have an expo app for our partner businesses and we sometimes encounter server error 504. This is on a production server!

Screen Shot 2020-01-13 at 1.57.05 PM|690x357

This is the logs from our node.js server hosted on heroku. Any idea on how to fix this?

1 Like

FYI: Receiving the same error message.

I have the same problem with the same config. Did you find a way to manage it ?

Hi Expo team,
I’m experiencing the same issue. Captured error from my notificaton function: Expo responded with an error with status code 504…

504 Gateway Time-out

History here is suggesting that similar issues in the past had to do with Expo server stability. May I check that is it something with Expo again or is it my code?

Here’s a snippet of my Firebase function:

return admin.firestore().getUserNotificationTokensSnapshot()
.then( snapshot => {
let notificationTokens = {}

        snapshot.forEach( doc => {
            const docID = doc.id
            const docData = doc.data()
            if ( docData.notification ) {

                const { expoToken } = docData.notification

                const tokenString = getTokenStringFromToken(expoToken)

                if ( tokenString ) {
                    notificationTokens[docID] = tokenString
                }
            }
        })

        const userIDs = Object.keys(notificationTokens)
        const now = Date.now()

        const notificationObjectKey = `${type}-${uid}-${now}`

        let messages = []

        for ( let i=0; i<userIDs.length; i++ ) {
            const pushToken = notificationTokens[userIDs[i]]
            if (Expo.isExpoPushToken(pushToken)) {
                messages.push({
                    to: pushToken,
                    sound: 'default',
                    title,
                    body,
                    data: {...notificationData, notificationObjectKey},
                })
            }
        }

        let chunks = expo.chunkPushNotifications(messages)
        let tickets = []

        return Promise.all(chunks.map(chunk => {
            return expo.sendPushNotificationsAsync(chunk)
                .then( ticketChunk => {
                    tickets.push(...ticketChunk);
                    return Promise.resolve(true)
                })
        }))
            .then( _ => {
                let receiptIds = [];
                for (let ticket of tickets) {
                    if (ticket.id) {
                        receiptIds.push(ticket.id);
                    }
                }

                //function to update receipts in the firebase 
            })
            .then( _ => {
                console.log('done!')
                return {
                    success: true
                }
            })
            .catch( e => {
                console.log('err: ', e.message)
                return {
                    success: false,
                    errorCode: 'unknown',
                    errorMessage: e.message
                }
            })

    })

There have been some more reports recently on github. Linking there for reference EXPO notifications is not reliable · Issue #6486 · expo/expo · GitHub

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