For JavaScript Pusher-compatible clients it's irrelevant as these can gracefully handle missing property. However, using Laravel Reverb as Pusher server for mobile application on iOS platform - written in Flutter and using forked official Pusher package (https://pub.dev/packages/pusher_channels_flutter) to allow server details customization - makes websocket unusable for apps that rely on that event, as Pusher Swift implementation does not properly parse payload and does not emit subscription_succeeded, which makes it impossible to react for such event.
Solving problem
To make data property available in event payload we could simply remove empty($data) condition in EventHandler::formatPayload method and assign result of JSON encoding directly to that property, as following:
But this solution will result in payload containing data: '[]'. To be fully compatible with Pusher official server I suggest to modify mentioned condition and return string '{}' instead of null for empty data, and encoded JSON for other cases.
I've prepared PR for this solution.
Best regards!
Steps To Reproduce
Very basic Laravel application with installed Reverb and JavaScript Echo connecting to websocket channel will provide described results.
Reverb Version
1.0.0-beta4
Laravel Version
11.1.1
PHP Version
8.3.4
Description
Hello!
This issue targets missing
data
property inpusher_internal:subscription_succeeded
event, in response to connecting to private or public channel.Overview
Official Pusher server provides following payload for previously mentioned event:
This can be easily verfied with JavaScript example after creating sandbox app in Pusher.
Laravel Reverb does not send
data
property for such event:For JavaScript Pusher-compatible clients it's irrelevant as these can gracefully handle missing property. However, using Laravel Reverb as Pusher server for mobile application on iOS platform - written in Flutter and using forked official Pusher package (https://pub.dev/packages/pusher_channels_flutter) to allow server details customization - makes websocket unusable for apps that rely on that event, as Pusher Swift implementation does not properly parse payload and does not emit
subscription_succeeded
, which makes it impossible to react for such event.Solving problem
To make
data
property available in event payload we could simply removeempty($data)
condition inEventHandler::formatPayload
method and assign result of JSON encoding directly to that property, as following:But this solution will result in payload containing
data: '[]'
. To be fully compatible with Pusher official server I suggest to modify mentioned condition and return string'{}'
instead of null for empty data, and encoded JSON for other cases.I've prepared PR for this solution.
Best regards!
Steps To Reproduce
Very basic Laravel application with installed Reverb and JavaScript Echo connecting to websocket channel will provide described results.