Client.available() function rerun value is asways 1

  1. AMB82 MINI
  2. Arduino SDK (Adruino IDE 2.2.1)
  3. The source code is as follows.

  1. in ref documents, WiFi - client.available() returns the number of bytes available for reading.
    but in above source code, When connected to the server, availavble() rerurns always 1 regardless of whether the server sends a message or not.
    and When connected to the server, the program doesn’t seem to execute beyond line 37 in the source code. The code beyond line 37 executes only when the connection to the server is terminated.
    (of course, It works correctly on the ESP32 platform with the same source code)

Could you please provide some guidance or advice

Dear Realtek

Please check if the source code is wrong or if there is a problem with the available() function

Hi @time4china, please give us some time to troubleshoot this.

Thank you.

I am experiencing the same problem. Any advice would be appreciated.

Hi @time4china , can you help me test in line 89 of WifiClient.cpp? change return 1 to return ret; with this screenshot here. Let me know if this fix work for you.

Dear Kelvin

  1. I changed wificlient.cpp as below (return 1 → return ret)

  2. Unfortunately, the result is same as before.
    problem is not solved.

please check again. please

Hi @time4china, my bad, give me some more time to debug. thanks

Hi @time4china,

When you create the WiFiClient, can you set non blocking mode and test again?

WiFiClient client(NON_BLOCKING_MODE);

after setting WiFiClient client(NON_BLOCKING_MODE);

problem is solved,

thank you very much.

Proposed solutions did not work for me.
I commented out line 93 and it works.

1 Like