parse-community / node-apn

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

issue with push 20k devices in one go #142

Closed evle closed 6 months ago

evle commented 6 months ago

I got an error while I pushing 20k devices in one go

 VError: apn write failed: Stream closed with error code NGHTTP2_ENHANCE_YOUR_CALM
    at ClientHttp2Stream.<anonymous> (/Users/max/test/link/app/node_modules/@parse/node-apn/lib/client.js:287:19)
    at ClientHttp2Stream.emit (node:events:514:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  jse_shortmsg: 'apn write failed',
  jse_cause: Error [ERR_HTTP2_STREAM_ERROR]: Stream closed with error code NGHTTP2_ENHANCE_YOUR_CALM
      at new NodeError (node:internal/errors:405:5)
      at ClientHttp2Stream._destroy (node:internal/http2/core:2346:13)
      at _destroy (node:internal/streams/destroy:109:10)
      at ClientHttp2Stream.destroy (node:internal/streams/destroy:71:5)
      at Http2Stream.onStreamClose (node:internal/http2/core:552:12) {
    code: 'ERR_HTTP2_STREAM_ERROR'
  },

here's my code snippet

apnProvider.send(n, generateNotifications(20000)).then(res=>{
    console.log('!!!!', res.failed[0].error)
}).catch(e=>{
    console.log(e)
})

Are there any suggestions for pushing a large number of devices? Or should the user design the concurrent control by themselves?

parse-github-assistant[bot] commented 6 months ago

Thanks for opening this issue!

mtrezza commented 6 months ago

The error is self-explanatory, you'll need queuing.