mac-cain13 / notificato

Takes care of Apple push notifications (APNS) in your PHP projects.
MIT License
224 stars 44 forks source link

Wrep/Notificato/Apns/Gateway.php READ_TIMEOUT #63

Open jrots opened 5 years ago

jrots commented 5 years ago

Hi is there a reason why the variable READ_TIMEOUT in SslSocket is not configurable? What we're seeing now is a timeout of 1 second on each push notification request to apple.. because the reply is always empty...

Push notifications are most of the time fire & forget imho, the reply doesn't matter ...

Will fork this library and put the variable to 0 but would be nice if this configurable and that I can continue to use this library.

Thanks!

mac-cain13 commented 5 years ago

Not sure if I agree that push notifications are fire and forget. There are 2 reasons why it's important to read what Apple is responding;

  1. Apple can return an error about the push notification (incorrect payload, payload too long, certificate invalid, etc) think you want to know about that so you know that users are not receiving the notifications
  2. Even if the notification is not important and you don't care if it isn't delivered we still need to read for errors because Apple will close the socket when an error occurs. So all following notifications on the same connection will not be received by Apple, even though they are valid

Correctly reading SSL errors in combination with the way PHP is handling sockets was in fact the hardest part of getting this library right. So I think READ_TIMEOUT shouldn't be exposed as an option and it's also not the best idea to change this in a fork.

nnrudakov commented 5 years ago

@mac-cain13, so if I want to send a message to 1M devices then I have to wait (READ_TIMEOUT * 1M devices / 1M microseconds) seconds. 1M seconds I have to wait in worst case. Do you think is it OK? How many messages in second your lib can send? Do you test it?