pushok icon indicating copy to clipboard operation
pushok copied to clipboard

Laravel Vapor - HTTP/2 stream 15 was not closed cleanly before end of the underlying stream

Open ryangittings opened this issue 1 year ago • 3 comments

Hey all,

I'm getting an issue in Laravel Vapor that I can't recreate locally. Stack trace attached:

Exception: HTTP/2 stream 15 was not closed cleanly before end of the underlying stream in /var/task/vendor/edamov/pushok/src/Client.php:161
Stack trace:
#0 /var/task/vendor/laravel-notification-channels/apn/src/ApnChannel.php(79): Pushok\Client->push()
#1 /var/task/vendor/laravel-notification-channels/apn/src/ApnChannel.php(58): NotificationChannels\Apn\ApnChannel->sendNotifications(Object(Pushok\Client), Object(NotificationChannels\Apn\ApnMessage), Array)
#2 /var/task/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(148): NotificationChannels\Apn\ApnChannel->send(Object(App\Models\User), Object(App\Notifications\NewEpisode))

Thank you!

ryangittings avatar Apr 12 '23 08:04 ryangittings

Sounds similar to my recent issue. Hmm. Perhaps Apple changed something on their end?

yetdog avatar Jun 04 '23 17:06 yetdog

Hey there, did either of you happen to find a solution?

ahinkle avatar Jul 27 '23 15:07 ahinkle

Only thing I did (that worked for me) is break the push messages up into chunks of 10000 tokens per client object

So for each group of 10000 tokens, here's my pseudo-code:

$client = new Client($authProvider, $production = $pushenv);
$client->setAutoCloseConnections ( true );
$client->setNbConcurrentRequests( 40 );
$client->setMaxConcurrentConnections( 15 );
$client->addNotifications($notifications); //have previously built the $notifications array

$responses = $client->push();

$client->close();
unset($client);
unset($notifications);

I loop through that however many times it takes to get through all the tokens and it seems to be working.

yetdog avatar Jul 27 '23 15:07 yetdog