title: Symfony 3: Curl GET timeout when used from a controller but work from command side
body: <p>I try to find a solution to this problem for the past few days but i dont find what is the issue here.</p>
  
  <p>So the problem is simple but realy weird. I cant use curl (GET) from a controller in symfony.</p>
  
  <p>I try to implement a simple form, You enter your mail in a form, send it, then it called the API from haveibeenpwned.com (great site, you should check ! ). The answer is basicly telling you if your mail has been "hacked", by sending you a json format string.</p>
  
  <p>So i try my code in a simple php script. -> OK</p>
  
  <p>Try my code in a command, and use the command on the server. -> OK</p>
  
  <p>I call the command in my controller. -> FAIL
  I test my curl script in the controller. -> FAIL</p>
  
  <p>All time the code fail it's always "error : Failed connect to haveibeenpwned.com:443; Operation now in progress"</p>
  
  <p>But since the code actualy work in a simple PHP script, and when i used the command I create on server side, i dont understant why the controller fail.</p>
  
  <p>Here are the command</p>
  
  <pre><code>class checkMailCommand extends ContainerAwareCommand {
  protected function configure()
  {
      $this
          -&gt;setName('curl:checkMail')
          -&gt;setDescription('Check Mail')
          -&gt;addArgument('emailCheck', InputArgument::REQUIRED, 'What\'s the email address we check?');
  }
  
  protected function execute(InputInterface $input, OutputInterface $output)
  {
      $account = $input-&gt;getArgument('emailCheck');
  
      $curl = curl_init();
  
      curl_setopt_array($curl, array(
          CURLOPT_URL =&gt; "https://haveibeenpwned.com/api/v2/breachedaccount/".$account,
          CURLOPT_RETURNTRANSFER =&gt; true,
          CURLOPT_TIMEOUT =&gt; 30,
          CURLOPT_HTTP_VERSION =&gt; CURL_HTTP_VERSION_1_1,
          CURLOPT_CUSTOMREQUEST =&gt; "GET",
          CURLOPT_HTTPHEADER =&gt; array(
              "User-Agent: Pwnage-Checker-For-Safe-Portal",
              "api-version: 2"
          ),
      ));
      $output-&gt;writeln($curl);
  
      $response = curl_exec($curl);
      $err = curl_error($curl);
  
      curl_close($curl);
  
      if ($err){
          $output-&gt;writeln("error : ".$err);
      }
      else{
          $output-&gt;writeln($response);
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>and the controller function:</p>
  
  <pre><code>    public function checkMailAction(Request $request)
  {
      $form = $this-&gt;createForm(checkMailType::class);
      $form-&gt;handleRequest($request);
      $message = null;
      $response = null;
      if ($form-&gt;isSubmitted() &amp;&amp; $form-&gt;isValid()) {
          $kernel = $this-&gt;get('kernel');
          $application = new Application($kernel);
          $application-&gt;setAutoExit(false);
  
          $input = new ArrayInput(array(
              'command' =&gt; 'curl:checkMail',
              'emailCheck' =&gt; $form["checkMail"]-&gt;getdata()
          ));
  
          $output = new BufferedOutput();
  
          $application-&gt;run($input, $output);
  
          // return the output
          $response = $output-&gt;fetch();
  
          //$response = json_decode($response, true);
      }
  
      return $this-&gt;render('EXTgetcurlBundle:hibp:check.html.twig', array(
          "message"               =&gt; $message,
          "response"               =&gt; $response,
          "form"                  =&gt; $form-&gt;createView(),
      ));
  }
  </code></pre>
  
  <p>To be very clear, this code is working like a charm when i use it on my server, with the command </p>
  
  <pre><code>php bin/console curl:checkMail [mail] 
  </code></pre>
  
  <p>and when i use it inside a simple test.php" and print_r the result.</p>
  
  <p>If someone have any idea, it would be very appreciate.</p>