AndrewBarba / apns2

Node client for connecting to Apple's Push Notification Service using the new HTTP/2 protocol with JSON web tokens
MIT License
118 stars 32 forks source link

Can not send more than MAX_CONNECTIONS at once #17

Closed sisoje closed 6 years ago

sisoje commented 6 years ago

I have an array of notifications and it fails to send them if there is more than MAX_CONNECTIONS in array.

sisoje commented 6 years ago

Here is my code: client.send(notifications) .then(() => { context.log('notifications done', notifications.length) context.done() }) .catch(err => { context.log('notifications done', notifications.length) context.log('error', err) context.done() })

sisoje commented 6 years ago

When executing nothing happens - no success no error

sisoje commented 6 years ago

will i have trouble if i put MAX_CONNECTIONS to 1000?

AndrewBarba commented 6 years ago

Definitely don't increase MAX_CONNECTIONS to 1000, I'm looking into this and will report back

sisoje commented 6 years ago

ok thanks

AndrewBarba commented 6 years ago

I found the issue, pushing a new version now

AndrewBarba commented 6 years ago

Fixed in v4.0.4: https://github.com/AndrewBarba/apns2/releases/tag/4.0.4

dimaqq commented 3 years ago

Hello, I'm a contributor to https://github.com/HENNGE/aapns and I wonder how this project solved this particular issue. IIRC, when the connection is created, the client has to assume "max connections", typically 100, while the server is going to lower this to 1 very quickly afterwards. It does so because when authentication is done by a token, there's no authentication until the first request. After first request passes authentication check, the server will re-instate reasonable "max connections". I solved this by artificially restricting connection concurrency until one response indicates OK. I'm curious what approach this library takes.