<p>MtGox uses CloudFlare for DDOS protection.  It's possible that your IP is being blocked.</p>

<p>Open a ticket with MtGox and tell them your IP... they may likely whitelist it.</p>

CC BY-SA 3.0
2013-05-22T21:43:54.337Z
i just tried it from a different ip with sleep set to 2 minutes. still the same problem occurs
symbiont
CC BY-SA 3.0
2013-05-22T21:47:19.850Z
This might be the built in limits they have for this API.  Try using WebSockets
makerofthings7
CC BY-SA 3.0
2013-05-25T15:26:25.800Z
built in limits doesn't explain why it still works in my browser. WebSockets would require a lot of changes (i'm using visual studio 2008).
symbiont
CC BY-SA 3.0
2013-05-25T16:45:22.353Z
Launch fiddler and do a comparison of what's happening (useragent etc)
makerofthings7
CC BY-SA 3.0
2013-05-20T11:57:55.087Z
2013-05-20T11:57:55.087Z
makerofthings7
<p>i wrote a simple function to retrieve trades from mtgox with following HTTP API call:</p>

<pre><code>https://data.mtgox.com/api/1/BTCUSD/trades?since
</code></pre>

<p>documented here: <a href="https://en.bitcoin.it/wiki/MtGox/API/HTTP/v1#Multi_currency_trades" rel="nofollow">https://en.bitcoin.it/wiki/MtGox/API/HTTP/v1#Multi_currency_trades</a></p>

<p>here's the function:</p>

<pre><code>string GetTradesOnline(Int64 tid)
{
    Thread.Sleep(30000);

    // communicate
    string url = "https://data.mtgox.com/api/1/BTCUSD/trades?since=" + tid.ToString();
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    StreamReader reader = new StreamReader(response.GetResponseStream());

    string json = reader.ReadToEnd();
    return json;
}
</code></pre>

<p>i'm starting at tid=0 to get the data from the very beginning. it works fine for 5 requests &amp; responses. but then the following line throws a "System.Net.WebException", saying that "The operation has timed out":</p>

<pre><code>HttpWebResponse response = (HttpWebResponse)request.GetResponse();
</code></pre>

<p>this exception keeps being thrown even if i catch it and retry. it's always exactly at 5 requests.</p>

<p>while it has been failing for a couple of minutes, i try the 6th request in the browser and it works just fine while the function continues to fail.</p>

<p>the strange thing is that it works for 5 requests everytime i start the application. currently, i always start at trade id 0 (tid=0).</p>

<p>i've increased the Sleep() inbetween requests to 2 minutes but it still behaves the same.</p>

<p>if i change the url to <a href="https://www.google.com" rel="nofollow">https://www.google.com</a>, it doesn't timeout.</p>

<p><strong>any ideas of what could be wrong?</strong></p>

<development><mtgox><api><c#>
MtGox http api "trades since" requests keep being timed out
symbiont
# MtGox http api "trades since" requests keep being timed out

(Asked by: username_0 on 2013-05-20)

i wrote a simple function to retrieve trades from mtgox with following HTTP API call:

```
https://data.mtgox.com/api/1/BTCUSD/trades?since

```

documented here: <https://en.bitcoin.it/wiki/MtGox/API/HTTP/v1#Multi_currency_trades>

here's the function:

```
string GetTradesOnline(Int64 tid)
{
    Thread.Sleep(30000);

    // communicate
    string url = "https://data.mtgox.com/api/1/BTCUSD/trades?since=" + tid.ToString();
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    StreamReader reader = new StreamReader(response.GetResponseStream());

    string json = reader.ReadToEnd();
    return json;
}

```

i'm starting at tid=0 to get the data from the very beginning. it works fine for 5 requests & responses. but then the following line throws a "System.Net.WebException", saying that "The operation has timed out":

```
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

```

this exception keeps being thrown even if i catch it and retry. it's always exactly at 5 requests.

while it has been failing for a couple of minutes, i try the 6th request in the browser and it works just fine while the function continues to fail.

the strange thing is that it works for 5 requests everytime i start the application. currently, i always start at trade id 0 (tid=0).

i've increased the Sleep() inbetween requests to 2 minutes but it still behaves the same.

if i change the url to <https://www.google.com>, it doesn't timeout.

**any ideas of what could be wrong?**

**Tags:** development, mtgox, api, c#


---

## 1 answers

### Answer by username_1 on 2013-05-20. Score: 1

MtGox uses CloudFlare for DDOS protection. It's possible that your IP is being blocked.

Open a ticket with MtGox and tell them your IP... they may likely whitelist it.

> **Comments:**
> **username_0**: i just tried it from a different ip with sleep set to 2 minutes. still the same problem occurs  
> **username_1**: This might be the built in limits they have for this API.  Try using WebSockets  
> **username_0**: built in limits doesn't explain why it still works in my browser. WebSockets would require a lot of changes (i'm using visual studio 2008).  
> **username_1**: Launch fiddler and do a comparison of what's happening (useragent etc)  

---

