0

I'm a new user of this platform and I'm trying to integrate Mercure into Symfony by following the documentation: https://symfony.com/blog/symfony-gets-real-time-push-capabilities . Once all the steps in the console are followed of chrome to the response of the Publisher class an error is generated:

net :: ERR_ABORTED 406.

Could you help me to understand how to make this bundle work?

namespace App\Controller;

use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Mercure\Publisher;
use Symfony\Component\Mercure\Update;

class PublishController
{
    public function __invoke(Publisher $publisher)
    {
        $update = new Update(
            'http://example.com/books/1',
            json_encode(['status' => 'OutOfStock'])
        );


        // The Publisher service is an invokable object
        $publisher($update);
    }
}

const es = new EventSource('https://www.davidecpr.online/hub?topic=' + encodeURIComponent('http://example.com/books/1'));
            es.onmessage = e => {
                // Will be called every time an update is published by the server
                console.log(JSON.parse(e.data));
            };

The .env variable is set like this: 'MERCURE_PUBLISH_URL' => 'http://www.davidecpr.online:3000/hub'

SecretAgentMan
  • 2,856
  • 7
  • 21
  • 41
  • The URL using to publish (`http://www.davidecpr.online:3000/hub`) and to subscribe (`https://www.davidecpr.online/hub`) aren't the same. Is it intended? Your problem looks like a config issue. – Kévin Dunglas Aug 09 '19 at 06:10
  • I think I might be able to help you but I need to see your composer.json can you provide it? – B0re Jan 24 '20 at 15:09

0 Answers0