khoih-prog / Portenta_H7_AsyncWebServer

Asynchronous WebServer Library for STM32H7-based Portenta_H7 using mbed_portenta core. This library, which is relied on Portenta_H7_AsyncTCP, is part of a series of advanced Async libraries, such as AsyncTCP, AsyncUDP, AsyncWebSockets, AsyncHTTPRequest, AsyncHTTPSRequest, etc. Now supporting using CString in optional SDRAM to save heap to send very large data
GNU Lesser General Public License v3.0
12 stars 3 forks source link

Cannot send more than 4 characters from server -> client #5

Closed 1IfByLAN2IfByC closed 2 years ago

1IfByLAN2IfByC commented 2 years ago

I am unable to send a message to the client that is more than 4X characters long. I am able to reliably receive/decode on my my client (python+websockets), however, if the message from Portenta_H7_AsyncWebServer is longer than 4 characters, I get a ProtocolError: reserved bits must be 0 error which triggers a disconnect.

to reproduce:

void onEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventType type, void * arg, uint8_t *data, size_t len){
  if(type== WS_EVT_CONNECT){
    Serial.println("WS Connected!");
    client->text("Hey"); // works
  }
    else if(type == WS_EVT_DISCONNECT)
  {
    //client disconnected
    Serial.println("ws disconnect");
  }
  else if(type == WS_EVT_DATA){
    AwsFrameInfo * info = (AwsFrameInfo*)arg;
    if(info->final && info->index == 0 && info->len == len)
    {
      //the whole message is in a single frame and we got all of it's data

      if(info->opcode == WS_TEXT)
      {
        data[len] = 0;
        Serial.println("New MSG");
        client->text("12535");  // fails
      } 

There is no problem on the server receiving arbitrarly long messages, so it doesn't seem like a buffer issue?

Currently using:

Arduino_MachineControl v.1.1.0 Portenta_H7_AsyncTCP v 1.3.2 Portenta_H7_AsyncWebServer v. 1.2.1

The Portenta is using Arduino Mbed OS Portenta Boards v 3.0.0

khoih-prog commented 2 years ago

Hi @1IfByLAN2IfByC

Thanks for using the library.

It seems that you adapt the code from Async WebSocket Plugin

I suggest that you first use ESP32 and follow ESP32 HTTP webserver: receiving textual data in websocket to test your code first to be sure your code / server are OK, before moving ahead to Portenta_H7

Then post the issue here whenever there is a proven bug of this library.

It's totally your problem, and nobody can help you out with such minimal posted info. Please include at least Minimal, Reproducible Example if posted somewhere else for help.

I'm closing the issue now and only reopen after a bug has been proven.

Good Luck,