-->
Page 1 of 2

client.connected() error

PostPosted: Thu Jun 22, 2017 8:02 am
by Albx
Hello!
I have a problem with connection my esp8266-12e with a server.
my sketch is:
Code: Select all#include <ESP8266WiFi.h>

char* ssidRete;
char* pswRete;

const char* host = "www.google.it";
int count;

void setup() {
  WiFi.mode(WIFI_AP_STA);

  delay(1000);
  Serial.begin(115200); 
  Serial.println("**********");
  ssidRete = "xxxx";
  pswRete ="yyyyy";
  WiFi.begin(ssidRete, pswRete);
  count=0;
}
 void loop() {
  WiFiClient client;

  Serial.println(client.connect(host, 80));
 
  if (!client.connect(host, httpPort)) {
    return;
  }

   if (client.connected()) {
     client.stop();  // DISCONNECT FROM THE SERVER
   } 
   count +=1;
   Serial.println(count);
   Serial.println();
   Serial.println("closing connection");
   delay(200);
 }


it works for 120 request and then crashes with reset esp.
the code of exception is:
Exception (29):
epc1=0x4000e1b2 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

ctx: sys


Tanks and sorry for my english

Re: client.connected() error

PostPosted: Mon Jun 26, 2017 7:50 am
by Albx
Thank you philbowles for the reply.
yes this looks like special code to demo the problem (code is very simplified).
I was wrong in this example to define the client object, which in reality is declared in global scope
but the problem does not change and I'm sure the connection exists.
For precision, code works regularly if I changed host = "www.google.it" with
host = "data.sparkfun.com"
Thanks again for your availability

Re: client.connected() error

PostPosted: Tue Jun 27, 2017 5:08 am
by Albx
Thank you philbowles for the reply.
yes this looks like special code to demo the problem (code is very simplified).
I was wrong in this example
to define the client object, which in reality is declared in global scope
but the problem does not change and I'm sure the connection exists.
For precision, code works regularly if I changed host = "www.google.it" with
host = "data.sparkfun.com"
Thanks again for your availability

Re: client.connected() error

PostPosted: Wed Jun 28, 2017 3:26 pm
by gbafamily1