title: Symfony 5 Mercure Failed to send an update SSL connect error for "https://127.0.0.1:8000/.well-known/mercure"
body: <p>i'm student and beginner,  sorry in advance if i don't understand.
  I try to use Symfony 5 with mercure but i have some difficulty to send an update to the hub.
  i check the document to  <a href="https://symfony.com/doc/5.4/mercure.html#basic-usage" rel="nofollow noreferrer">Symfony Mercure doc</a> and think to make a good part about that but not all.</p>
  <p>i have installed docker on my windows 10 and i install Mercure directly by the Symfony cli like is write on the doc.
  my parameter is the parameter by default that the cli install.
  .env</p>
  <pre><code>        ###&gt; symfony/mercure-bundle ###
      # See https://symfony.com/doc/current/mercure.html#configuration
      # The URL of the Mercure hub, used by the app to publish updates (can be a local URL)
      MERCURE_URL=https://127.0.0.1:8000/.well-known/mercure
      # The public URL of the Mercure hub, used by the browser to connect
      MERCURE_PUBLIC_URL=https://127.0.0.1:8000/.well-known/mercure
      # The secret used to sign the JWTs
      MERCURE_JWT_SECRET=&quot;secret&quot;
  ###&lt; symfony/mercure-bundle ###
  </code></pre>
  <p>i use a true JWT secret is just for exemple([JWT.io])<a href="https://jwt.io/" rel="nofollow noreferrer">2</a>.</p>
  <pre><code>{
    &quot;mercure&quot;: {
      &quot;publish&quot;: [
        &quot;*&quot;
      ]
    }
  }
  </code></pre>
  <p>with my secret password.</p>
  <p>i create an js file with the eventSource.</p>
  <pre><code>const eventSource = new EventSource('http://127.0.0.1:8000/.well-known/mercure?topic=' + encodeURIComponent('http://127.0.0.1:8000/commande/recapitulatif'),
      );
  eventSource.onmessage = event =&gt; {
      // Will be called every time an update is published by the server
      alert(&quot;Commande&quot;);
      console.log(JSON.parse(event.data));
  }
  </code></pre>
  <p>and i would like a notification to be send when somebody access to the recap order : <a href="http://127.0.0.1:8000/commande/recapitulatif" rel="nofollow noreferrer">http://127.0.0.1:8000/commande/recapitulatif</a>.
  In my controller when the address <a href="http://127.0.0.1:8000/commande/recapitulatif" rel="nofollow noreferrer">http://127.0.0.1:8000/commande/recapitulatif</a> is call i add:</p>
  <pre><code> $update = new Update(
              'http://127.0.0.1:8000/commande/recapitulatif',
              json_encode(['status' =&gt; 'Commande'])
          );
  
          $hub-&gt;publish($update);
  </code></pre>
  <p>on the page where i need to have the notification and add the js code, if i check the connection with mercure in network of the app dev of chrome i can see this:</p>
  <pre><code>Request URL: http://127.0.0.1:8000/.well-known/mercure?topic=http%3A%2F%2F127.0.0.1%3A8000%2Fcommande%2Frecapitulatif
  Request Method: GET
  Status Code: 200 OK
  Remote Address: 127.0.0.1:8000
  Referrer Policy: strict-origin-when-cross-origin
  </code></pre>
  <p>but when i try to go to the url <a href="http://127.0.0.1:8000/commande/recapitulatif" rel="nofollow noreferrer">http://127.0.0.1:8000/commande/recapitulatif</a> i have an error (Failed to send an update) and (SSL connect error for &quot;https://127.0.0.1:8000/.well-known/mercure&quot;.)</p>
  <p>Update:
  i change</p>
  <pre><code>MERCURE_URL=https://127.0.0.1:8000/.well-known/mercure
  
  MERCURE_PUBLIC_URL=https://127.0.0.1:8000/.well-known/mercure
  </code></pre>
  <p>to</p>
  <pre><code>MERCURE_URL=http://127.0.0.1:8000/.well-known/mercure
  
  MERCURE_PUBLIC_URL=http://127.0.0.1:8000/.well-known/mercure
  </code></pre>
  <p>and now with the error (failed to send an update) i have (HTTP/1.1 401 Unauthorized returned for &quot;http://127.0.0.1:8000/.well-known/mercure&quot;.)</p>
  <p>probably i need to put my app to https for have a ssl connection with mercure ?</p>
  <p>An other try.
  i replace hhttp where i change https to http to my .env and js file.
  After that i change the code in my controller like this:</p>
  <pre><code> $discovery-&gt;addLink($request);
  
      $response = new JsonResponse([
          '@id' =&gt; 'http://127.0.0.1:8000/commande/recapitulatif',
          'status' =&gt; 'Order',
      ]);
  
      $response-&gt;headers-&gt;setCookie(
          $authorization-&gt;createCookie($request, ['http://127.0.0.1:8000/commande/recapitulatif'])
      );
  </code></pre>
  <p>Now i don't have error but nothing is notified to my brower.</p>
  <p>my log for the page i want notification:</p>
  <pre><code>[Application] Jun 26 17:33:45 |DEBUG  | SECURI Stored the security token in the session. key=&quot;_security_main&quot;
  [Web Server ] Jun 26 19:33:45 |INFO   | SERVER GET  (200) /favicon.ico ip=&quot;127.0.0.1&quot;
  [Application] Jun 26 17:33:46 |INFO   | REQUES Matched route &quot;_wdt&quot;. method=&quot;GET&quot; request_uri=&quot;http://127.0.0.1:8000/_wdt/8f2711&quot; route=&quot;_wdt&quot; route_parameters={&quot;_controller&quot;:&quot;web_profiler.controller.profiler::toolbarAction&quot;,&quot;_route
  &quot;:&quot;_wdt&quot;,&quot;token&quot;:&quot;8f2711&quot;}
  [Web Server ] Jun 26 19:33:47 |INFO   | SERVER GET  (200) /_wdt/8f2711 ip=&quot;127.0.0.1&quot;
  </code></pre>
  <p>and the log where i need to send the notificaton:</p>
  <pre><code>[Application] Jun 26 17:36:06 |DEBUG  | SECURI Stored the security token in the session. key=&quot;_security_main&quot;
  [Web Server ] Jun 26 19:36:06 |INFO   | SERVER POST (200) /commande/recapitulatif host=&quot;127.0.0.1:8004&quot; ip=&quot;127.0.0.1&quot; scheme=&quot;https&quot;
  [Application] Jun 26 17:36:07 |INFO   | REQUES Matched route &quot;_wdt&quot;. method=&quot;GET&quot; request_uri=&quot;http://127.0.0.1:8000/_wdt/d13a0f&quot; route=&quot;_wdt&quot; route_parameters={&quot;_controller&quot;:&quot;web_profiler.controller.profiler::toolbarAction&quot;,&quot;_route
  &quot;:&quot;_wdt&quot;,&quot;token&quot;:&quot;d13a0f&quot;}
  [Web Server ] Jun 26 19:36:08 |INFO   | SERVER GET  (200) /_wdt/d13a0f ip=&quot;127.0.0.1&quot;
  </code></pre>
  <p>but if i add the update like this:</p>
  <pre><code> $update = new Update(
                  'http://127.0.0.1:8000/commande/recapitulatif',
                  json_encode(['status' =&gt; 'Commande']), true
              );
  
              $hub-&gt;publish($update);
  </code></pre>
  <p>my log are like this:</p>
  <pre><code>[Application] Jun 26 18:02:39 |INFO   | HTTP_C Request: &quot;POST http://127.0.0.1:8000/.well-known/mercure&quot;
  [Application] Jun 26 18:02:39 |INFO   | HTTP_C Response: &quot;401 http://127.0.0.1:8000/.well-known/mercure&quot;
  [Application] Jun 26 18:02:39 |CRITICA| REQUES Uncaught PHP Exception Symfony\Component\Mercure\Exception\RuntimeException: &quot;Failed to send an update.&quot; at C:\laragon\www\Projet\Restaurant\RelaisDesVoutes\vendor\symfony\mercure\src\H
  ub.php line 104
  [Web Server ] Jun 26 20:02:39 |INFO   | MERCUR Topic selectors not matched, not provided or authorization error
  [Web Server ] Jun 26 20:02:39 |WARN   | SERVER POST (401) /.well-known/mercure host=&quot;127.0.0.1:8004&quot; ip=&quot;127.0.0.1&quot; scheme=&quot;https&quot;
  [Application] Jun 26 18:02:39 |DEBUG  | SECURI Stored the security token in the session. key=&quot;_security_main&quot;
  [Web Server ] Jun 26 20:02:39 |ERROR  | SERVER POST (500) /commande/recapitulatif host=&quot;127.0.0.1:8004&quot; ip=&quot;127.0.0.1&quot; scheme=&quot;https&quot;
  </code></pre>
  <p>If somebody can help me to understand where is my problem, thank you verry much.</p>