Answers.Body: <p>The problem was the service that was supposed to return the JSON feed was not returning <em>anything</em>. Meaning our server was simply waiting for a response that never arrived and eventually timing out a minute later.</p>
  
  <p>I only discovered this by writing my own script to test for a response from two different servers, discovering the IP address of the server experiencing the problem was being blocked from accessing the JSON feed.</p>
  
  <p>Please, if you're supplying data and decide to block someone's IP, at least tell them you're doing so. An error response would have saved me a lot of work.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-28T12:57:39.027Z
Answers.LastActivityDate: 2017-02-28T12:57:39.027Z
Answers.UserDisplayName: Clive Portman
Body: <p>Not sure whether this is a Craft thing or a Yii thing, but I have this exact same code running on two servers that I've freshly updated Apache, PHP, etc. On the one server it runs fine but on the other the page never loads and I have to do a server reboot to clear it.</p>
  
  <p>Can anyone think of any reason this might happen?</p>
  
  <pre><code>$url = 'https://domain.com/jsonfeed'
  try {
      $client = new \Guzzle\Http\Client();
      $request = $client-&gt;get($url);
  
      // BREAK NOW AND ALL IS FINE
  
      $response = $request-&gt;send();
  
      // BREAK NOW AND PAGE NEVER LOADS SO IT MUST BE
      // $request-&gt;send(); THAT IS FAILING
  
      if (!$response-&gt;isSuccessful()) {
          return;
      }
  
      $items = $response-&gt;json();
  
      reset($items);
      $key = key($items);
      return $items[$key][$id];
  
  } catch(\Exception $e) {
      return;
  }
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-02-24T00:34:57.737Z
Comments.Text: Anything in the Apache error logs? I'd guess environmental differences (memory limits, execution times, etc.) Probably worth comparing those on the servers.
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-02-24T12:53:48.897Z
Comments.Text: Thanks Brad. It turned out the providers of the JSON feed had blocked our access but weren't providing an error response. That meant the request had to wait to time out and the website was unresponsive until then. I'm not sure of the solution if it happens again - clearly the site has to wait for a response in case it is just delayed.
Comments.UserDisplayName: Clive Portman
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-02-24T21:40:40.210Z
Comments.Text: Yeah... they should be returning a 403 response header or something similar in that case.  Oh well... would you mind adding that as an official answer?
Comments.UserDisplayName: Brad Bell
Tags: <plugin-development>
Title: $request->send fails on one server but not the other
ThreadText: # $request->send fails on one server but not the other
  
  (Asked by: username_0 on 2017-02-23)
  
  Not sure whether this is a Craft thing or a Yii thing, but I have this exact same code running on two servers that I've freshly updated Apache, PHP, etc. On the one server it runs fine but on the other the page never loads and I have to do a server reboot to clear it.
  
  Can anyone think of any reason this might happen?
  
  ```
  $url = 'https://domain.com/jsonfeed'
  try {
      $client = new \Guzzle\Http\Client();
      $request = $client->get($url);
  
      // BREAK NOW AND ALL IS FINE
  
      $response = $request->send();
  
      // BREAK NOW AND PAGE NEVER LOADS SO IT MUST BE
      // $request->send(); THAT IS FAILING
  
      if (!$response->isSuccessful()) {
          return;
      }
  
      $items = $response->json();
  
      reset($items);
      $key = key($items);
      return $items[$key][$id];
  
  } catch(\Exception $e) {
      return;
  }
  
  ```
  
  **Tags:** plugin-development
  
  > **Comments:**
  > **username_1**: Anything in the Apache error logs? I'd guess environmental differences (memory limits, execution times, etc.) Probably worth comparing those on the servers.  
  > **username_0**: Thanks username_1. It turned out the providers of the JSON feed had blocked our access but weren't providing an error response. That meant the request had to wait to time out and the website was unresponsive until then. I'm not sure of the solution if it happens again - clearly the site has to wait for a response in case it is just delayed.  
  > **username_1**: Yeah... they should be returning a 403 response header or something similar in that case.  Oh well... would you mind adding that as an official answer?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2017-02-28. Score: 1 | Accepted answer
  
  The problem was the service that was supposed to return the JSON feed was not returning *anything*. Meaning our server was simply waiting for a response that never arrived and eventually timing out a minute later.
  
  I only discovered this by writing my own script to test for a response from two different servers, discovering the IP address of the server experiencing the problem was being blocked from accessing the JSON feed.
  
  Please, if you're supplying data and decide to block someone's IP, at least tell them you're doing so. An error response would have saved me a lot of work.
  
  
  ---
  
  