is it possible to have esp as webserver & web client simultaneously

hiii all,

can anyone clarify my doubt about why i am unable to have one nodemcu 1.0 as web client and web server simultaneously. the wifi mode is set to ap+sta mode. i can use it as a web server from both end(through access point & through station mode hitting to the local ip). but same time no data can be posted on a thingspeak server. so please someone just guide me what i have done wrong. thanks in advance. the code is as follow

#include “HX711.h” //You must have this library in your arduino library folder
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <ESP8266HTTPClient.h>

String apiKey = “#############”;
const char *ssid = “@@@@@@@”;
const char *password = “!!!”;
const char *ssid1 = “%%%%%%%%%%%%”;
const char *password1 = “^^^^^^^^^”;
const char *ssid2 = “&&&&&&&&&&&”;
const char password2 = “***********”;
const char
server1 = “api.thingspeak.com”;
#define DOUT D5//A1
#define CLK D6//A0
byte mac[6];

ESP8266WiFiMulti wifiMulti;
ESP8266WebServer server(8001);
WiFiClient client;

HX711 scale;
int j,i=0;
float reading[10];
long zero_factor;
//Change this calibration factor as per your load cell once it is found you many need to vary it in thousands
float calibration_factor = -22805;//22685; //-106600

void handleRoot(); // function prototypes for HTTP handlers
void getinfo();
void handleNotFound();

//=============================================================================================
// SETUP
//=============================================================================================
void setup()
{
Serial.begin(9600);
delay(1000);
Serial.println(“HX711 Calibration”);
Serial.println(“Remove all weight from scale”);
delay(2000);
scale.begin(DOUT,CLK);//(A1, A0);
scale.set_scale();
scale.tare(); //Reset the scale to 0
zero_factor = scale.read_average(50); //Get a baseline reading
Serial.print("Zero factor: "); //This can be used to remove the need to tare the scale. Useful in permanent scale projects.
Serial.println(zero_factor);
scale.set_offset(-297492);
scale.set_scale(calibration_factor);
delay(5000); //Adjust to this calibration factor
WiFi.softAP(ssid, password);
Serial.print(“AP IP address: “);
Serial.println(WiFi.softAPIP());
Serial.println(“Connected to “);
Serial.println(ssid);
WiFi.mode(WIFI_AP_STA);
wifiMulti.addAP(ssid1, password1);
wifiMulti.addAP(ssid2, password2);
Serial.println(“Connecting Wifi…”);
while(wifiMulti.run() != WL_CONNECTED)
{
delay(500);
Serial.print(”.”);
}
if(wifiMulti.run() == WL_CONNECTED)
{
Serial.println(””);
Serial.println(“WiFi connected”);
Serial.println(“IP local address: “);
Serial.println(WiFi.localIP());
Serial.println(“Connected to “);
Serial.println(WiFi.SSID());
}
if (!MDNS.begin(“esp8266”))
{ // Start the mDNS responder for esp8266.local
Serial.println(“Error setting up MDNS responder!”);
}
Serial.println(“mDNS responder started”);
server.on(”/”, handleRoot);
server.on(”/conn_info”,getinfo);
server.begin();
Serial.println(“HTTP server started”);
// j=1;

WiFi.softAPmacAddress(mac);
Serial.print(“soft ap mac address: “);
Serial.print(mac[0],HEX);
Serial.print(”:”);
Serial.print(mac[1],HEX);
Serial.print(":");
Serial.print(mac[2],HEX);
Serial.print(":");
Serial.print(mac[3],HEX);
Serial.print(":");
Serial.print(mac[4],HEX);
Serial.print(":");
Serial.print(mac[5],HEX);
Serial.println(":");

WiFi.macAddress(mac);
Serial.print(“normal mac address: “);
Serial.print(mac[0],HEX);
Serial.print(”:”);
Serial.print(mac[1],HEX);
Serial.print(":");
Serial.print(mac[2],HEX);
Serial.print(":");
Serial.print(mac[3],HEX);
Serial.print(":");
Serial.print(mac[4],HEX);
Serial.print(":");
Serial.print(mac[5],HEX);
Serial.println(":");
}

void loop()
{
server.handleClient();
if(!(millis()%2000))//60000
{
scale.power_up();
// Serial.print("Reading: ");
reading = scale.get_units();
// Serial.print(reading*, 3);*
// Serial.print(" kg\t"); //Change this to kg and re-adjust the calibration factor if you follow SI units like a sane person
// Serial.print(" calibration_factor: ");
// Serial.print(calibration_factor);
// Serial.println();
* delay(3);*
* i++;*
* scale.power_down();
_
if(i==10)//180*_
* {*
* float sum=0;*
* for(int p=0;i>p;p++)*
* {*
* sum+=reading[p];*
* }*
* sum/=i;*
* sendDataToServer(sum);*
* Serial.println();*
* Serial.println();*
* Serial.println("$$$$$$$$$$$$$$$$$$$$$$$");*
* Serial.println("#######################");*
* Serial.print(j++,DEC);*
* Serial.print("\t time :");*
* Serial.print(millis()/60000,DEC);*
* Serial.print(“mins\t”);*
* Serial.print(“average value =”);*
* Serial.println(sum/10,2);*
* Serial.println("#######################");*
* Serial.println("$$$$$$$$$$$$$$$$$$$$$$$");*
* Serial.println();*
* i=0;*
* }*
* }*
}
void sendDataToServer(float sum)
{
* Serial.println(“sendDataToServer”);*
* if(client.connect(server1,80)) // “184.106.153.149” or api.thingspeak.com*
* { *
* Serial.print(“server is connected”);*
* String postStr = apiKey;*
* postStr +="&field1=";*
* postStr += String(sum,2);*
* postStr += “\r\n\r\n”;*
* client.print(“POST /update HTTP/1.1\n”);*
* client.print(“Host: api.thingspeak.com\n”);*
* client.print(“Connection: close\n”);*
* client.print(“X-THINGSPEAKAPIKEY: “+apiKey+”\n”);*
* client.print(“Content-Type: application/x-www-form-urlencoded\n”);*
* client.print("Content-Length: ");*
* client.print(postStr.length());*
* client.print("\n\n");*
* client.print(postStr);*
* Serial.println("%. Sent to Thingspeak.");*
* }*
* else*
* Serial.println(“connection failed”);*
* client.stop();*
}
void handleRoot()
{
_ ************************8_
_
}
_
void handleNotFound()
_
{
_
_ ************************8_
_
}
_
void getinfo()
_
{
_
_ **************************8_
_
}
_

hiii,
after some debugging i get to know that when i dont start the ap mode, then the data is posted to the thingspeak server properly. now my question is how can i manage to hit the web server through station mode only when the wifi mode is in sta+ap mode. please share your valuable ideas.