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.
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!
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
}
})
})