SocketException using Wifi_RS21 Module

Hi,

I’ve just received the Wifi module and after updating the Spider’s firmware and letting it deploy the Wifi module’s firmware at runtime I have hit a problem when trying an HttpRequest.

The module scans for and connects to my network fine, then inside the NetworkUp Event Handler I am trying to get an HttpResponse from a generic website like www.google.com.

I have tried HttpWebRequest, WebRequest and Gadgeteer.WebClient but they all throw the following exception:


 #### Exception System.Net.Sockets.SocketException - CLR_E_FAIL (1) ####
    #### Message: 
    #### Microsoft.SPOT.Net.SocketNative::getaddrinfo [IP: 0000] ####
    #### System.Net.Dns::GetHostEntry [IP: 0008] ####
    #### System.Net.HttpWebRequest::EstablishConnection [IP: 00e1] ####
    #### System.Net.HttpWebRequest::SubmitRequest [IP: 0013] ####
    #### System.Net.HttpWebRequest::GetResponse [IP: 000c] ####
    #### WifiModule.Program::wifi_NetworkUp [IP: 0058] ####
    #### Gadgeteer.Modules.Module+NetworkModule::OnNetworkEvent [IP: 004d] ####
    #### System.Reflection.MethodBase::Invoke [IP: 0000] ####
    #### Gadgeteer.Program::DoOperation [IP: 001a] ####
    #### Microsoft.SPOT.Dispatcher::PushFrameImpl [IP: 004a] ####
    #### Microsoft.SPOT.Dispatcher::PushFrame [IP: 001d] ####
    #### Microsoft.SPOT.Dispatcher::Run [IP: 0006] ####
    #### Gadgeteer.Program::Run [IP: 001c] ####
    #### WifiModule.Program::Main [IP: 001a] ####
    #### SocketException ErrorCode = -1
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in Microsoft.SPOT.Net.dll
    #### SocketException ErrorCode = -1
    #### SocketException ErrorCode = -1
    #### SocketException ErrorCode = -1
    #### Exception System.Net.WebException - 0x00000000 (1) ####
    #### Message: host not available
    #### System.Net.HttpWebRequest::EstablishConnection [IP: 00f1] ####
    #### System.Net.HttpWebRequest::SubmitRequest [IP: 0013] ####
    #### System.Net.HttpWebRequest::GetResponse [IP: 000c] ####
    #### WifiModule.Program::wifi_NetworkUp [IP: 0058] ####
    #### Gadgeteer.Modules.Module+NetworkModule::OnNetworkEvent [IP: 004d] ####
    #### System.Reflection.MethodBase::Invoke [IP: 0000] ####
    #### Gadgeteer.Program::DoOperation [IP: 001a] ####
    #### Microsoft.SPOT.Dispatcher::PushFrameImpl [IP: 004a] ####
    #### Microsoft.SPOT.Dispatcher::PushFrame [IP: 001d] ####
    #### Microsoft.SPOT.Dispatcher::Run [IP: 0006] ####
    #### Gadgeteer.Program::Run [IP: 001c] ####
    #### WifiModule.Program::Main [IP: 001a] ####

Am I using the API wrong? If not, can anyone see another problem with what I’m doing?

Thanks,

Poncho

Below are me 3 pieces of test code:

System.Net.HttpWebRequest req = new System.Net.HttpWebRequest();
            req.RequestUri = "http://www.google.com";
            req.GetResponse();
System.Net.WebRequest wr = System.Net.WebRequest.Create("http://www.google.com");
            System.Net.WebResponse wre = wr.GetResponse();
HttpRequest req = WebClient.GetFromWeb("http://www.google.com");
            req.ResponseReceived += new HttpRequest.ResponseHandler(req_ResponseReceived);

I think the problem is that the board is not aware of a DNS server in your network. You might want to use DHCP.

Ah okay, I’ll test that now.

I the WebClient way the correct way of requesting http data?

Thanks.

Ah yes, that worked thanks.

Also using WebClient worked too.

Thanks for the fast response Wouter.

You’re welcome