parse-community / node-apn

Apple Push Notification module for Node.js
Other
177 stars 64 forks source link

VError: apn write timeout #38

Closed cbratschi closed 3 years ago

cbratschi commented 3 years ago

Recently I am getting this error after sending about 11k push messages of 22k. The app was restarted and the behavior is the same.

VError: apn write timeout
2020-12-11 14:44 +00:00:       at ClientHttp2Stream.<anonymous> (/node_modules/@parse/node-apn/lib/clie
nt.js:207:34)
       at Object.onceWrapper (events.js:420:28)
       at ClientHttp2Stream.emit (events.js:314:20)
       at callTimeout (internal/http2/core.js:2181:8)
       at ClientHttp2Stream._onTimeout (internal/http2/core.js:1882:5)
       at listOnTimeout (internal/timers.js:554:17)
       at processTimers (internal/timers.js:497:7) {
     jse_shortmsg: 'apn write timeout',
     jse_info: {}
}

It seems the push messages are still processed by Apple.

davimacedo commented 3 years ago

Are you sending these pushes using Parse Server or node-apn directly?

cbratschi commented 3 years ago

They are sent through @parse/node-apn.

davimacedo commented 3 years ago

You can increase the timeout using the requestTimeout option in the config object and/or set your app to retry the message that has timed out.

cbratschi commented 3 years ago

I only see requestTimeout in the documentation but not in the source code. Is this value still being used and how can it be set?

cbratschi commented 3 years ago

Well, found it in the source code but somehow GitHub search did not list it. We have a lot of tokens and therefore it will take longer for later tokens. I will try it and update this ticket later.

cbratschi commented 3 years ago

Set the timeout to 30 s and now the requests work fine.

alexibz commented 3 years ago

I had the same error message popup and in my case it was because I didn't define a topic for the notification. (I am upgrading from an old version of node-apn).