You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\Serializer\SerializerInterface;
...
$key = $_ENV['MERCURE_PUBLISHER_JWT_KEY'];
$jwt = JWT::encode([], $key);
$eventTopicData = $this->serializer->serialize([
'event' => 'new_message',
'topic' => $topic,
'jwt' => $jwt,
'Authorization' => 'Bearer ' . $jwt,
'payload' => ['test'],
], "json");
$update = new Update(
$topic,
$eventTopicData,
true // false does not work too
);
$this->messageBus->dispatch($update);
<?php
namespace App\Mercure;
use Lcobucci\JWT\Builder;
use Lcobucci\JWT\Signer\Hmac\Sha256;
use Lcobucci\JWT\Signer\Key;
class JwtProvider
{
private $secret;
public function __construct(string $secret)
{
$this->secret = $secret;
// this one called
}
public function __invoke(): string
{
// but never triggered, no errors
return (new Builder())
->withClaim('mercure', ['publish' => []])
->getToken(new Sha256(), new Key($this->secret));
}
}
It is built somewhere here during symfony bundle init, but it is never invoked!
/**
* @author Kévin Dunglas <dunglas@gmail.com>
*/
final class MercureExtension extends Extension
{
So, from what I understand, something wrong with dispatching events.
It happened after upgrading legacy mercure binary to the latets build with caddy GO lang server and moving it to separate server.
Subscriptions seems to be working, but events are never dispatched now.
Spent a lot of time trying to figure out is this mercure, caddy or symfony bundle, or transport (Redis) issue.
But because JwtToken is never applied, could be smth wrong with the bundle during invocation or dispatching.
Caddy server does not receives any updates, post requests according to logs.
Tell me please what could be the issue?
The text was updated successfully, but these errors were encountered:
Why it was failing silently and throwing nothig, never invoking JWTTokenProvide do not know and have no time right now to debug.
Still, right now caddy server responds with 401 for that token generated in JWTProvider, need to debug it further.
Okay, that was fixed too by removing private option for Update
$update = new Update(
$topic,
$eventTopicData
// here TRUE will make update private
);
Now update is sent, but never accepted on UI with mentioned in SYmfony docs EventSourcePolyfill, polyfill just sends requests again and again but never streams events to susbcribers.
From logs we can see that events are sent to mercure hub and idspatched to topice subscribers. https://symfony.com/doc/current/mercure.html#authorization ":"http.handlers.mercure","msg":"Update sent","subscriber":{"id":"urn:uuid:b5b53747-1567-4704-bc6b-b2841eadf34c" Yaffle/EventSource#163 Yaffle/EventSource#79
Docs used
https://symfony.com/doc/current/mercure.html#configuration
https://mercure.rocks/spec
https://caddyserver.com/docs/json/apps/http/servers/routes/handle/mercure/
https://mercure.rocks/docs/hub/install
It is built somewhere here during symfony bundle init, but it is never invoked!
caddyfile config
caddy logs, we see only new susbcribers and handling GET requests
,"request":{"remote_addr":"ip-123123","proto":"HTTP/2.0","method":"OPTIONS","host":"remove.mercure.api","uri":"/.well-known/mercure/subscriptions/test"
So, from what I understand, something wrong with dispatching events.
It happened after upgrading legacy mercure binary to the latets build with caddy GO lang server and moving it to separate server.
Subscriptions seems to be working, but events are never dispatched now.
Spent a lot of time trying to figure out is this mercure, caddy or symfony bundle, or transport (Redis) issue.
But because JwtToken is never applied, could be smth wrong with the bundle during invocation or dispatching.
Caddy server does not receives any updates, post requests according to logs.
Tell me please what could be the issue?
The text was updated successfully, but these errors were encountered: