HttpRequest SendRequest never finished (never fired response receive)

Hi.


        public static void Post()
        {
            if (Program.ethernet.IsNetworkUp)
            {
                POSTContent content = POSTContent.CreateTextBasedContent("{\"data1\": \"test\"}");
                HttpRequest request = Gadgeteer.Networking.HttpHelper.CreateHttpPostRequest(@ "http://localhost/Smarthouse/Process/Microcontroler.php", content, "application/json");
                request.ResponseReceived += new HttpRequest.ResponseHandler(request_ResponseReceived);
                request.SendRequest();
                while (!request.IsReceived)
                    Thread.Sleep(1000);
                
                bool b = request.IsReceived;
            }
        }

        static void request_ResponseReceived(HttpRequest sender, HttpResponse response)
        {
            var i = 0;
        }

Program.ethernet is reference to J11D module. I get the IP and DNS servers. But I never get to var i = 0 or bool b = request.IsReceived line.

The basic idea is that I want to post some data to PHP.

Maybe I have problems with setting connections.
The whole code is:

    public partial class Program
    {
        void ProgramStarted()
        {
            Debug.Print("Program Started");

            if (!ethernet_J11D.Interface.IsOpen)
                ethernet_J11D.Interface.Open();

            NetworkInterfaceExtension.AssignNetworkingStackTo(ethernet_J11D.Interface);

            ethernet_J11D.NetworkUp += new GTM.Module.NetworkModule.NetworkEventHandler(ethernet_J11D_NetworkUp);
            ethernet_J11D.UseDHCP();

        }

        void ethernet_J11D_NetworkUp(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state)
        {
            POSTContent content = POSTContent.CreateTextBasedContent("{\"data1\": \"test\"}");
            HttpRequest request = Gadgeteer.Networking.HttpHelper.CreateHttpPostRequest(@ "http://localhost/Smarthouse/Process/Microcontroler.php", content, "application/json");
            request.ResponseReceived += new HttpRequest.ResponseHandler(request_ResponseReceived);
            request.SendRequest();
            while (!request.IsReceived)
                Thread.Sleep(1000);

            bool b = request.IsReceived;
        }

        void request_ResponseReceived(HttpRequest sender, HttpResponse response)
        {
            if (response.StatusCode == "202")
            {
            }
        }
    }

I get error:

[quote]The thread ‘’ (0x3) has exited with code 0 (0x0).
#### Exception System.Net.Sockets.SocketException - CLR_E_FAIL (10) ####
#### Message:
#### Microsoft.SPOT.Net.SocketNative::connect [IP: 0000] ####
#### System.Net.Sockets.Socket::Connect [IP: 001d] ####
#### System.Net.HttpWebRequest::SubmitRequest [IP: 0019] ####
#### System.Net.HttpWebRequest::GetRequestStream [IP: 0008] ####
#### SocketException ErrorCode = 10054
#### SocketException ErrorCode = 10054
A first chance exception of type ‘System.Net.Sockets.SocketException’ occurred in Microsoft.SPOT.Net.dll
#### SocketException ErrorCode = 10054
#### SocketException ErrorCode = 10054
#### Exception System.Net.WebException - 0x00000000 (10) ####
#### Message: connection failed
#### System.Net.HttpWebRequest::EstablishConnection [IP: 0168] ####
#### System.Net.HttpWebRequest::SubmitRequest [IP: 0019] ####
#### System.Net.HttpWebRequest::GetRequestStream [IP: 0008] ####
A first chance exception of type ‘System.Net.WebException’ occurred in System.Http.dll
A first chance exception of type ‘System.Net.WebException’ occurred in System.Http.dll

An exception occured while connecting to the Internet. Please, make sure that a valid URL is used and a network connection is up.

connection failed
The thread ‘’ (0xa) has exited with code 0 (0x0).[/quote]

See if changing

request.KeepAlive

and/or

request.Timeout

makes a difference.

HttpRequest does not have KeepAlive or Timeout.
CreateHttpPostRequest returns Gadgeteer.Networking.HttpRequest.
I double check and I can confirm that URL exists.

Same as in the other thread. Use real ip address of your server instead of localhost.

Lame, lame, lame, lame.
Thanks. I would break my head on this one.

By the way. It is also not working on 127.0.0.1. But it perfectly works on some domain.