Pages: [1] 2   Go Down
Author Topic: Ethernet Shield (Wiz5100) Probles with reoccuring requests  (Read 1199 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

Im new to EtherNet problems. Im IT literate, but I lack understanding low level electronics. (eq.which way electrons really go + or -)

Im setting up home automation based on Arduino Uno r3 (orginal); Ethernet (china); Attiny84/NRF24L01+ nodes with DS18b20.

Problem Im facing is related to hosting/EhterNet Shield.

FatCow Shared Hosting giving me really poor support with HTTP debugging, and honestly I believe they block my WIZ5100 requests.

I'm using PuTTy on ubuntu to diagnose open ports "80", and got really strange results that don't help.

When connecting via EtherNet, using standard arduino sketches for URL/DNS Server host(i dont have ip number), everything works fine first time. I get trough server, send lines of GET, read the file in serial monitor.

BUT when test things and try few GET requests(one at the time.. no loops yet) I get this never ending "connecting..." on my second or third attempt! Dont know how to move forward.

To sum up:
Using this code:
http://arduino.cc/en/Tutorial/WebClient
My hosting shuts down or after 3rd attempt within 2minutes from firs one.

Please help.



Tom.
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 138
Posts: 5837
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have no problems with this example sketch in the playground.
http://playground.arduino.cc/Code/WebClient
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have no problems with this example sketch in the playground.
http://playground.arduino.cc/Code/WebClient

Thanks.
Im happy for you.

...on the side line, any one else with post I could benefit?
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 138
Posts: 5837
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

My bad. Here is "Perfect World" code to modify the webclient turtorial.
Code:
void loop()
{
  while(client.connected()) {
    while (client.available()) {
      char c = client.read();
      Serial.print(c);
    }
  }

  client.stop();
  Serial.println(F("disconnected"));
  while(true);
}
Logged

Emsworth, UK
Offline Offline
Full Member
***
Karma: 8
Posts: 199
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote from: arduino_node
To sum up:
Using this code:
http://arduino.cc/en/Tutorial/WebClient
My hosting shuts down or after 3rd attempt within 2minutes from firs one.

Please help.
Can you post the url you are trying to retrieve? 
Better still copy and paste your sketch, or at least the parts you changed.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Server is being hosted by fatcow.com
It is shared but its not free.
I dont have SSH.
Telnet should be able test its port 80 butreturns garbage.

First attempt ok, rest hangs. No reply from server, even after 3min.

ill send code later.
Logged

Offline Offline
Full Member
***
Karma: 10
Posts: 170
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

so you are using the WebClient-sketch that connects a single time and then waits forever in while(true)?
Do you reset to execute the next request-attempt?

If so it could be the local-port is allways the same after reset so you cannot connect because the other side drops the packets as duplicates.

- Norbert
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Norbert,
Thats the clues Im looking for! I think on my end Hardware is ok , I managed to do all test stuff on my local ip.

Quote
so you are using the WebClient-sketch that connects a single time and then waits forever in while(true)?
Yes. This is how I test if it works. Yes while loop is there too. But it freezes on "connecting..." even after I hard reset the board, unplugg it and plug back on (power+ether)

Quote
Do you reset to execute the next request-attempt?
No. how to reset?
How to instruct not cashing of packets?
PHP string request is different every time (different tempC), but it is probable to have identical requests(time stamp is in PHP itself)

Quote
it could be the local-port is always the same after reset
Can I change ports from my Ethernet shield?
What is the solution if this is the case? modify my .htaccess ?

Im not fluent on HTTP/1.1 protocol, but please pint me in right stuff. (http://www.jmarshall.com/easy/http/).

Thank you.
Logged

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9470
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If your code fails after 3 times, then your connection to the server is probably not being closed properly in your code. Below is some simple client test code you can try to see if you can make repeated connections to my ISP's web server.

Code:
//zoomkat 9-22-12
//simple client test
//for use with IDE 1.0.1
//with DNS, DHCP, and Host
//open serial monitor and send an e to test
//for use with W5100 based ethernet shields
//remove SD card if inserted

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address

char serverName[] = "web.comporium.net"; // zoomkat's test web page server
EthernetClient client;

//////////////////////

void setup(){

  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    while(true);
  }

  Serial.begin(9600);
  Serial.println("Better client test 9/22/12"); // so I can keep track of what is loaded
  Serial.println("Send an e in serial monitor to test"); // what to do to test
}

void loop(){
  // check for serial input
  if (Serial.available() > 0) //if something in serial buffer
  {
    byte inChar; // sets inChar as a byte
    inChar = Serial.read(); //gets byte from buffer
    if(inChar == 'e') // checks to see byte is an e
    {
      sendGET(); // call sendGET function below when byte is an e
    }
  } 
}

//////////////////////////

void sendGET() //client function to send/receive GET request data.
{
  if (client.connect(serverName, 80)) {  //starts client connection, checks for connection
    Serial.println("connected");
    client.println("GET /~shb/arduino.txt HTTP/1.1"); //download text
    client.println("Host: web.comporium.net");
    client.println(); //end of get request
  }
  else {
    Serial.println("connection failed"); //error message if no client connect
    Serial.println();
  }

  while(client.connected() && !client.available()) delay(1); //waits for data
  while (client.connected() || client.available()) { //connected or data available
    char c = client.read(); //gets byte from ethernet buffer
    Serial.print(c); //prints byte to serial monitor
  }

  Serial.println();
  Serial.println("disconnecting.");
  Serial.println("==================");
  Serial.println();
  client.stop(); //stop client

}

Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I've used your code and its brilliant.

but here fatcow reply to your code:
Code:
==================

connected
HTTP/1.1 200 OK
Date: Tue, 26 Nov 2013 23:13:34 GMT
Content-Type: text/html
Content-Length: 84
Connection: keep-alive
Server: Apache/2
X-Powered-By: PHP/5.2.17

Timestamp is 31/12/1969 19:00:00unix epoh is 1385507614Your table has been populatedÿÿÿÿÿÿÿÿÿÿÿÿÿÿ<.....>ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
disconnecting.
==================

Timestamp is 31/12/1969 19:00:00unix epoh is 1385507614Your table has been populated this is PHP confirming.
There are 28625 of those "ÿ",
 ive just  put <...> to save some screen smiley-wink

i believe those would go on forever but ethernet buffer is only 2kb.
it takes 20 seconds on uno

after unix timestamp my server returns som wired stuff as you can see.

i was trying to get some code together to truncate that string, but no luck.

do you know what are they sending?
Logged

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9470
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
do you know what are they sending?

You might try making the same request with a web browser and see what is returned.
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Offline Offline
Full Member
***
Karma: 10
Posts: 170
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Do you reset to execute the next request-attempt?
No. how to reset?
I meant 'do you press the reset-button on your arduino to start the next attempt?'

Quote
it could be the local-port is always the same after reset
Can I change ports from my Ethernet shield?
you cannot without modifying the Ethernet-library. It's in EthernetClient.cpp Line 53. The problem is: whenever you reset the Arduino, the _localport is reset to 1024 as well.

What is the solution if this is the case? modify my .htaccess ?
If reuse of local port is the issue then there is absolutely nothing you can do on the http-protocoll-level (which is application) as this happens in tcp (which is transport).

What you can do: Make sure you don't have to reset, but write some logic that issues multiple-requests with some delay in between. (This ensures you don't reuse local port). Then make sure your connection is closed properly on each request so you don't run out of sockets. Your sketch waits for the other side to close, which just might not happen, so your client would stay in the 'while(client.connected()) {'-loop until you press reset. Add some kind of timeout here - if the reception of request takes longer than some seconds leave the loop and call client.stop().
Logged

Offline Offline
Full Member
***
Karma: 10
Posts: 170
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Timestamp is 31/12/1969 19:00:00unix epoh is 1385507614Your table has been populated this is PHP confirming.
There are 28625 of those "ÿ",
If this is the debug-output your arduino prints on the serial-line than you've run out of memory corrupting the Serial-devices buffer. Make sure you don't allocate memory for the whole response, but read the request in small chunks (calling returnsize = client.read(buffer,size) returns the number of bytes read, so you can use this for the next call to Serial.write(buffer,returnsize);
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks,

ntruchsess
Quote
(calling returnsize = client.read(buffer,size) returns the number of bytes read, so you can use this for the next call to Serial.write(buffer,returnsize);
I will reasearch this. thank you. if you have link handy, please post, if not .. google is my friend. (isnt really)
have you tested it somewhere, i was thinking that, if  I cannot get this server stop sending garbage, I would truncate the string only to essential query.
But this is only when I know the query lenght.
What about other uses? Im planning to adde weather xml pharsing, or logging through mysql. I dont know how long reply might get.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you,

Quote
Do you reset to execute the next request-attempt?
No. how to reset?
I meant 'do you press the reset-button on your arduino to start the next attempt?'
Yes I was reseting with button.

Quote
it could be the local-port is always the same after reset
Can I change ports from my Ethernet shield?
you cannot without modifying the Ethernet-library. It's in EthernetClient.cpp Line 53. The problem is: whenever you reset the Arduino, the _localport is reset to 1024 as well.
Noted. Thank you.

What is the solution if this is the case? modify my .htaccess ?
If reuse of local port is the issue then there is absolutely nothing you can do on the http-protocoll-level (which is application) as this happens in tcp (which is transport).
Noted. Thanks.

What you can do: Make sure you don't have to reset, but write some logic that issues multiple-requests with some delay in between. (This ensures you don't reuse local port). Then make sure your connection is closed properly on each request so you don't run out of sockets. Your sketch waits for the other side to close, which just might not happen, so your client would stay in the 'while(client.connected()) {'-loop until you press reset. Add some kind of timeout here - if the reception of request takes longer than some seconds leave the loop and call client.stop().
noted.Thank you.
Your script was running since 00:00GMT and still report ok every 15minutes.

Logged

Pages: [1] 2   Go Up
Jump to: