khoih-prog / WebSockets2_Generic

A WebSocket Server and Client library for Arduino, based on RFC6455, for writing modern Websockets applications. Now support ESP8266, ESP32 (including ESP32-S2 Saola, AI-Thinker ESP-12K, WT32_ETH01, etc.), nRF52, SAMD21, SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, Teensy, RP2040-based, etc. boards, with WiFiNINA, Teensy 4.1 NativeEthernet/QNEthernet, Ethernet W5x00 / ENC28J60 / LAN8742A / LAN8720, ESP8266 / ESP32-AT modules/shields, as well as SINRIC / Alexa / Google Home
GNU General Public License v3.0
81 stars 30 forks source link

Endless loop reading line from client #27

Closed izikkhv closed 3 years ago

izikkhv commented 3 years ago

Teensy41_NativeEthernet_tcp.hpp, line 103:

WSString readLine() override
{
  WSString line = "";

  int ch = -1;

  while ( ch != '\n' && available())
  {
    // It is important to call `client.available()`. Otherwise no data can be read.
    if (client.available())
    {
      ch = client.read();

      if (ch >= 0)
      {
        line += (char) ch;
      }
    }
  }

  return line;
}

sometimes client.available() return false, but available() still true then the loop is endless

khoih-prog commented 3 years ago

Thanks for your interest in the library.

Please follow the instructions in Issue: Bug report and provide at leas the MRE so that anyone can verify it it's a real issue.

Also noted that Teensy 4.1 NativeEthernet is still in infancy and buggy state, and check if there is any issue of that library.

I'll reopen the issue when the bug is proven.

Good Luck,