-
Notifications
You must be signed in to change notification settings - Fork 13.3k
client.write() is not working smoothly. After sending some data it getting halt for some seconds. #4118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You are not really helping us helping you. |
ESP8266 Arduino core version: 2.4.0 #include <time.h> const int CS = 16;// set GPIO16 as the slave select uint8_t resolution = 3; static const size_t bufferSize = 4096; //This demo can only work on OV2640_MINI_2MP or ARDUCAM_SHIELD_V2 platform. ArduCAM myCAM(OV2640, CS); const char* ssid = "3C2i4b0k"; const char* host = "192.168.137.1"; //WiFiClientSecure client; WiFiClient client; //************************************
} void captureAndUpload() size_t len = myCAM.read_fifo_length(); while (len) { void setup() { if (!SPIFFS.begin()) { //**************** //Check if the ArduCAM SPI bus is OK //Check if the camera module type is OV2640 void loop() {
while(client.available()){ } Output: Captured! The client.write() should have taken same time to upload the image to the server but that is not the case. whenever client.availableForWrite() is getting too low the client.write() is getting halt for some seconds and again resumes it's operation. |
We are not in multi-threading environment.
by
You can also try the MSS=1460 option in Tools menu since you seem to deal with big packets. |
while (!myCAM.get_bit(ARDUCHIP_TRIG , CAP_DONE_MASK)); I checked and the main cause of the delay is by the client.write() function. (Not always only when client.availableForWrite(); returning lower values. )
|
Would you be able to provide a tcpdump / wireshark capture of the traffic, only the part around when you observe such 5s delay ? |
sure. Just some minute. |
esp8266 tcp debug.zip |
It is difficult to isolate one of your loops by reading only the dumps since buffering on tcp side is asynchronous. They do not match your 4~5s lags. So what you can try is
And by writing these lines, I just realize that you are wearing your flash by using it as a buffer for every image. You just can directly send data: |
debugclientwrite.zip
client.write(f) is used because client.write(&stream) is much faster than client.write(buffer, will_copy);
just for testing.
The behavior is unpredictable/unstable. |
Thanks for the sketch. It turns out that the problem is apache. The sketch itself is doing well with local host: (ubuntu16.04, fresh apache+php install) remote host: (ADSL ping time is 30ms, downlink bw 20Mbits/s 14 hops, devuan-ascii) I am not a php/apache expert and I just don't know what happens, updated sketch
|
i'd like to add that I'm not sure the esp8266 is made to send such large data abroad with your QoS requirements (your dump shows you send your images to amazonaws). |
I also tested the sketch with node js server on aws ubuntu. The apache2 server is blocking tcp communication after there is some acknowledgement error. In both cases node.js and apache2 there is some acknowledgement error due to which the delay is getting increased. (in case of apache2: The server sending "tcp window full" massage due to the acknowledgement error sent by the esp8266.) below is the screenshot of the error massages in case of Apache (local host): below is the acknowledgement error in case of node js (aws server): |
The log you show are perfectly regular working TCP protocol. You saw the tcp-fast-retransmit algorithm in action, where a packet is lost, peer (server) aswering three times that a packet is lost, and sender (esp) restarting from where peer say the packet is lacking. Then transmission is going on. And you got your latency hole. What you have, other people had it too long ago. They realized that real time video transmission cannot work with TCP because TCP is an exact protocol and will retransmit lost data on purpose. So they made up new protocols and codecs for streaming which allow lost packets and which do not rely on TCP but rather on IP or UDP. So either
(1 or 2 are preferred though :). There's nothing more we can do in here. Things are working as expected. |
ok, |
@d-a-v Have you tried this type of scenarios with other SDKs.
This seems to be cheap. is it includes both (camera+raspberry pi)? can you provide link? |
I have been only using extensively the esp8266 nonos-SDK with arduino API. |
How "[LWIP] Fix the sequence number error of RST+ACK;" bug fixed by the official SDK relates to this issue? https://github.com/espressif/ESP8266_NONOS_SDK/releases/tag/v2.2.0 |
There is some problem in receiving acknowledgement of tcp packets.
The text was updated successfully, but these errors were encountered: