Issue with networking - Local is fine (but flawed), WAN server is not fine at all [SOLVED]

Hi all,

I’ve been having an issue making connections properly both online and locally, but more online. First I’ll show you the local running code that works fine (except for the client.available)

//server = a byte array comprising of the local IP address
//url is the web url typed as "www.website.com"
//data is a request string like this: "/folder/subfolder/?

    if (client.connect(server,clientPort))                             //Connect to server
{
  client.println("TEST");
  //client.flush();                                   //Send Break
    delay(200);
  while(client.available())
  {
    client.print("GET ");
    client.print(url);
    client.print(data);
    //client.println(" HTTP/1.1");
    //client.println("Connection: close");
    //client.print("Host: ");
    //client.println(url);
    //client.println("Accept: text/html, text/plain");
    client.println(" ");
    //client.flush();
      delay(200);

    //read server response
    Serial.println("Response: ");
    for(int i = 0; i<100; i++)
    {
      Serial.print(client.read());
    }
  }

So just to clarify… the issue with the server.available is that the server does never seem to be available. When I break the code inside that if statement out it runs fine though this is just something we were trying. Another issue with this code is that the response is always 100 -1s not any kind of meaningful message although it sends the data to my locally running application just fine.

So I made a hostgator website, and the code is the same except all that stuff is uncommented and the if statement reads

if (client.connect(url,clientPort))                             //Connect to server

I’ve been fliddling about for an hour or so trying to get this to work but to no avail with all sorts of combinations of code found from all over this forum and elsewhere .

I’m not putting this down purely to a code issue I think our server might be having issues as well. When I make a perfectly valid request through telnet to the server it gives me a 301 and tells me the document has moved and that its new location is exactly where I said it was!

If anybody could lend a hand I’d be very grateful, thank you in advance!

Well I managed to fix it pretty quickly…

turned out it did not like the www in the URL and didn’t require any header information other than the hostname

1 Like