Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By skrzyp
#41784 Hi!
I have trouble when I try to use server and client at the same time.
After few seconds, when client connect, webserver on esp end even ping don't respond, but communication betwen esp client and external server and of course WiFi connection still works.
Here is my simplified version of code:

Code: Select all#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266HTTPClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>

WiFiClient cl1;
ESP8266WebServer server(80);

char clConnect(){
  int ok=0,ret=0,cnt=0;
  char str[50];
  while(cnt<5){
      if (cl1.connect("server",port){
              return 1;
        }
     cnt++;
  }
  return 0;
}


void setup() {
 
  Serial.begin(115200);
  delay(100); 
   
  MDNS.begin("esp8266");
   
  WiFi.begin("WiFi", "Pass1234567");
  while (WiFi.status() != WL_CONNECTED) {
        delay(500);
        Serial.print(".");
  }
  Serial.println(WiFi.localIP());
 
  server.on("/", handleRoot);
  server.begin();
  clConnect();
 
}


Can someone told me what I doing wrong? Thanks