MtGox http api "trades since" requests keep being timed out 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 &amp; 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?
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.