c++ - Arduino hangs during multiple http requests on Linux but not on Windows -


i have problem when send http requests arduino linux mysql server. randomly hangs after requests (~150) on windows runs smoothly.

because of thinking problem not on arduino code somewhere else.

the linux server runs on raspberry pi (raspbian).

any suggestions?

the arduino code here

 if(!getpage(server,serverport)) serial.print(f("fail "));    byte getpage(ipaddress ipbuf,int thisport) {   int inchar;     serial.print(f("connecting..."));    if(client.connect(ipbuf,thisport))   {     serial.println(f("connected"));      strcpy(outbuf,"get /write3.php?value0=");     itoa(value0,tbuf,10);     strcat(outbuf,tbuf);      strcat(outbuf,"&value1=");     itoa(dht_humidity,tbuf,10);     strcat(outbuf,tbuf);      strcat(outbuf,"&value2=");     itoa(temperature,tbuf,10);     strcat(outbuf,tbuf);      strcat(outbuf,"&value3=");     itoa(pressure,tbuf,10);     strcat(outbuf,tbuf);      strcat(outbuf,"&value4=");     itoa(altitude,tbuf,10);     strcat(outbuf,tbuf);      strcat(outbuf,"&value5=");     itoa(gust,tbuf,10);     strcat(outbuf,tbuf);      strcat(outbuf,"&value6=");     itoa(dir,tbuf,10);     strcat(outbuf,tbuf);      strcat(outbuf,"&value7=");     itoa(rain,tbuf,10);     strcat(outbuf,tbuf);      strcat(outbuf,"&value8=");     itoa(knots,tbuf,10);     strcat(outbuf,tbuf);       client.write(outbuf);     client.println(" http/1.1");     client.println("host: 192.168.1.3");     client.println("connection: close");     client.println(); 

edit: hanged @ debug___3

serial.println("debug___2"); client.write(outbuf); serial.println("debug___3"); client.println(" http/1.1"); serial.println("debug___4"); client.println("host: 192.168.1.3"); serial.println("debug___5"); client.println("connection: close"); client.println(); 

i captured network traffic wireshark when hanged:

(large pics: hanged http request ---- successfull http request)

here http request hanged

enter image description here

and here successful request:

enter image description here

any ideas guys? still stuck there !!!

presuming outbuf not overflowed (it smaller maximum possible request string size , using strcat (source of evil))

the server may timeout in long time between when connection opened, , when send bytes. preconstruct outbuf ready go when connection opens.

strncat(outbuf,...,127); ... request constructed  if(client.connect(ipbuf,thisport)) {   client.write(outbuf);   client.println(" http/1.1");   client.println("host: 192.168.1.3"); ... 

to server, connection syn'd not used resource recovered. arduino slow, idle connection. syn flood old denial of service vector servers protect against.

a difference in timeout values explain why linux , win based server act different. confirm running wireshark on traffic. if server timing out on arduino, see sequence:

  • the syn handshake proceed between server , arduino
  • a little time passes
  • a rst server indicating connection dead
  • the arduino sends request string dead connection
  • the arduino program hangs @ client.write() because connection state out of sync
  • the client retrying - should see retransmissions

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -