title: Symfony + Mercure connection problems. Use HTTPS instead of HTTP
body: <p>I was trying to establish a connection between two docker containers. One as nginx server + Symfony application, and the second with Mercure.</p>
  <p>My application is working fine, docker-compose build also works without any problems. The problem is when I try to test it, and try to publish something to Mercure from Symfony App I got 500 internal server error with &quot;Failed to send an update.&quot; message.</p>
  <p>In the stack trace I can see that I got TransportException Error, with different env variable than I have in <strong>.env</strong> file. Application is trying to use HTTPS instead of HTTP that was defined in .env file.</p>
  <blockquote>
  <p>Symfony\Component\HttpClient\Exception\TransportException:
  SSL connect error for &quot;https://mercure/.well-known/mercure&quot;.
  at vendor/symfony/http-client/Chunk/ErrorChunk.php:65</p>
  </blockquote>
  <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=http://mercure/.well-known/mercure
  
  # The public URL of the Mercure hub, used by the browser to connect
  MERCURE_PUBLIC_URL=http://localhost:9090/.well-known/mercure
  
  MERCURE_PUBLISH_URL=http://mercure/.well-known/mercure
  
  # The secret used to sign the JWTs
  MERCURE_JWT_SECRET=&lt;Proper JWT Token is here&gt;
  ###&lt; symfony/mercure-bundle ###
  </code></pre>
  <p>In Mercure container I get:</p>
  <pre><code>mercure_1   | {&quot;level&quot;:&quot;debug&quot;,&quot;ts&quot;:1619097073.714639,&quot;logger&quot;:&quot;http.stdlib&quot;,&quot;msg&quot;:&quot;http: TLS handshake error from 172.21.0.5:57420: no certificate available for 'mercure'&quot;}
  </code></pre>
  <p>My docker-compose configuration</p>
  <pre><code>services:
  
      api:
          build:
              context: ./api
              dockerfile: Dockerfile
          volumes:
              - ./api:/app
              - ./api/storage/logs/php-fpm:/var/log/php-fpm
          networks:
              - redio_network
          ports:
              - &quot;7000:80&quot;
          environment:
              &lt;&lt;: *common-variables
  
      mercure:
          image: dunglas/mercure
          environment:
              MERCURE_PUBLISHER_JWT_KEY: '!ChangeMe!'
              MERCURE_SUBSCRIBER_JWT_KEY: '!ChangeMe!'
          ports:
              - &quot;9090:80&quot;
          networks:
              - redio_network
          volumes:
              - ./_data/caddy_data:/data
              - ./_data/caddy_config:/config
          command: /usr/bin/caddy run -config /etc/caddy/Caddyfile.dev
  </code></pre>
  <p>Here is my Controller, when I publish to a Mercure topic:</p>
  <pre><code>class ChatController extends AbstractController
  {
      /**
       * @Route(&quot;/push&quot;, name=&quot;push&quot;)
       * @param Request $request
       * @param HubInterface $publisher
       * @return Response
       */
      public function push(Request $request, HubInterface $publisher): Response
      {
          $publisher-&gt;publish(new Update(
              '/chat',
              json_encode(['message' =&gt; 'hello!'])
          ));
  
          return $this-&gt;json('Done');
      }
  }
  </code></pre>