Get request through esp8266 good response but truncated - ptoblem

hi.
mega + esp8266

i am sending Get request string to my shared server.
result code with http1.1 is 200 ok .
the body that comes after is truncated and usually only 40 charachters arrive through serial 1 connected to my esp8266 wifi.

the strange thing here is that when i am running this manualy step by step over serial console - it works great. no missing chars.

only when i try it runtime using serial1.serialavailable() , or looping serial1.read() it returns constantly 40 chars. and finito.

i tried to increase serial buffer to 256 and 512 in hardwareserial.h file , without success.

every delay i added in any of the stages just after sending the get request , or even while looping for serial1.read() changed aliitle bit , but not to total resolution.

i am lost and tired after 2 days trying all possibilities.

is there an issue of server configuration ?

is there an issue of buffer clearring ?

i can tell this is an issue - common - to lots wifi users.

heeeeeelp :stuck_out_tongue_closed_eyes: .

great day.

Oded.

Your code isn't showing

here is result i get over the console:-
the ����� are the nuls i get over loop waiting for charachters from server.

quote

serial started!
68
esp_alive
there is wifi
connecting to server
there is wifi
there is server

AT+CIPSEND
Recv 68 bytes

SEND OK

+IPD,333:HTTP/1.1 200 OK
Server:������������������������������������C

quote

the server responds good. but somehow chars are lost.

the code is runtime code not a step by step sequence over console.

thanks.

Oded.

Solved!

the magic was Serial1.readBytesUntil() function if i define it correctly.

reason for missing charachters was Serial (not Serial1 which passed data from server) doing stuff adjacent to serial1 in background.

serial is very realtime function thats sensitive to background "noises".

solution.

muting/waiting serial while serial1 passes data.

passing data from serial1 to an array rather then writing or printing to console.

after that - i handles the data received.

thats the core of the solution:-

char serialdata[100];

Serial1.readBytesUntil("Z", serialdata,100);}

int _count;

String _result ="";

while (_count< 100){

_result +=String( serialdata[_count]);

_count = _count+1;}

Serial.println("result"+_result);

hope i contributed something as a novice here.

thanks.