{"id":"2f13da29b806a448","repo":"laravel/framework","slug":"ably-error-s","errorCode":null,"errorMessage":"Ably error: %s","messagePattern":"Ably error: (.+?)","errorType":"exception","errorClass":"BroadcastException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Broadcasting/Broadcasters/AblyBroadcaster.php","lineNumber":134,"sourceCode":"     * Broadcast the given event.\n     *\n     * @param  array  $channels\n     * @param  string  $event\n     * @param  array  $payload\n     * @return void\n     *\n     * @throws \\Illuminate\\Broadcasting\\BroadcastException\n     */\n    public function broadcast(array $channels, $event, array $payload = [])\n    {\n        try {\n            foreach ($this->formatChannels($channels) as $channel) {\n                $this->ably->channels->get($channel)->publish(\n                    $this->buildAblyMessage($event, $payload)\n                );\n            }\n        } catch (AblyException $e) {\n            throw new BroadcastException(\n                sprintf('Ably error: %s', $e->getMessage())\n            );\n        }\n    }\n\n    /**\n     * Build an Ably message object for broadcasting.\n     *\n     * @param  string  $event\n     * @param  array  $payload\n     * @return \\Ably\\Models\\Message\n     */\n    protected function buildAblyMessage($event, array $payload = [])\n    {\n        return tap(new AblyMessage, function ($message) use ($event, $payload) {\n            $message->name = $event;\n            $message->data = $payload;\n            $message->connectionKey = data_get($payload, 'socket');","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/laravel/framework/blob/bd6b5437e6ad87bb49f9b426724f07a9f64e9683/src/Illuminate/Broadcasting/Broadcasters/AblyBroadcaster.php#L116-L152","documentation":"Thrown by AblyBroadcaster::broadcast() when the Ably SDK raises an AblyException during channel publish. The broadcaster wraps it into a BroadcastException with the sprintf 'Ably error: %s' message so all Ably failures surface uniformly. Broadcasting happens on the queue by default, so this often appears in failed jobs.","triggerScenarios":"Dispatching a ShouldBroadcast event on the ably connection with an invalid/expired Ably key, a rate-limited account, an invalid channel name, or when Ably's API is unreachable.","commonSituations":"ABLY_KEY misconfigured or expired; broadcasting on a connection that hits Ably rate limits; network outage to Ably endpoints; invalid channel name characters; running broadcasts synchronously (ShouldBroadcastNow) in a request so the error surfaces directly.","solutions":["Verify ABLY_KEY (and key/secret in config) are valid and not expired in the Ably dashboard.","Inspect the embedded Ably message to identify the specific cause (auth, rate limit, invalid channel).","Ensure events implement ShouldBroadcast (queued) not ShouldBroadcastNow so transient failures retry on the queue.","Configure queue retries/failed-job handling so transient Ably errors are reprocessed."],"exampleFix":"// before - .env\nABLY_KEY=\n// broadcast throws \"Ably error: ...\"\n\n// after\nABLY_KEY=xxxxx.yyyyy:zzzzz\n// and keep events queued so transient errors retry:\nclass OrderShipped implements ShouldBroadcast\n{\n    public function via(): array { return ['ably']; }\n}","handlingStrategy":"retry","validationCode":"if (empty(config('broadcasting.connections.ably.key'))) {\n    throw new RuntimeException('Ably key is not configured; broadcasting will fail.');\n}","typeGuard":"function ablyCredentialsAreConfigured(): bool\n{\n    return ! empty(config('broadcasting.connections.ably.key'));\n}","tryCatchPattern":"try {\n    broadcast(new OrderShipped($order));\n} catch (\\Illuminate\\Broadcasting\\BroadcastException $e) {\n    if (str_contains($e->getMessage(), 'Ably error')) {\n        // queue for retry; log the underlying cause\n        report($e);\n    } else {\n        throw $e;\n    }\n}","preventionTips":["Keep events queued (ShouldBroadcast, not ShouldBroadcastNow) so transient Ably errors retry via the queue.","Validate ABLY_KEY at deploy time with a health check.","Monitor Ably rate limits/quota in the dashboard to avoid publish failures."],"tags":["broadcasting","ably","network","queue","laravel"],"analyzedSha":"bd6b5437e6ad87bb49f9b426724f07a9f64e9683","analyzedAt":"2026-08-06T00:28:32.783Z","schemaVersion":2}