Friday 19 February 2010

Network problems

A few notes on an issue I have been experiencing. I had the following C# code that constantly threw a timeout error on line 5:

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://api-verify.recaptcha.net/verify");
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";

using (Stream stream = request.GetRequestStream())
{
    using (StreamWriter streamWriter = new StreamWriter(stream, Encoding.ASCII))
    {
        streamWriter.Write(postData);
        streamWriter.Close();
    }

    stream.Close();
}

ipconfig

Running ipconfig gives you nice information like your default gateway.

tracert

Running tracert for api-verify.recaptcha.net showed a hop to the default gateway (the first entry in the list of results) and nothing but timeouts thereafter.

Default gateway

A gateway is a routing device that knows how to pass traffic between different subnets and networks. It will know some routes to given IP addresses but not the routes to every address on the Internet. A gateway will will know the addresses of other gateways it can hand the traffic off to if the required route is unknown to it. A default gateway will be on the same subnet and is the gateway to be relied on when it doesn't know how to route traffic.

In this case, wrong default gateway?