<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>

CC BY-SA 3.0
2017-02-28T12:57:39.027Z
2017-02-28T12:57:39.027Z
Clive Portman
<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>

CC BY-SA 3.0
2017-02-24T00:34:57.737Z
Anything in the Apache error logs? I'd guess environmental differences (memory limits, execution times, etc.) Probably worth comparing those on the servers.
Brad Bell
CC BY-SA 3.0
2017-02-24T12:53:48.897Z
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.
Clive Portman
CC BY-SA 3.0
2017-02-24T21:40:40.210Z
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?
Brad Bell
<plugin-development>
$request->send fails on one server but not the other
# $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 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.  
> **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.


---

