ArduinoHTTPClient websocket未记录的最大消息大小?

ArduinoHTTPClient websocket未记录的最大消息大小?,websocket,arduino,Websocket,Arduino,我有一台Arduino MKRNB 1500(具有LTE-M网络能力)。 我的代码使用websocket将消息上载到服务器。消息每秒上传一次,大约800-1000字节。我的websocket服务器接受这些消息(我已尝试使用浏览器客户端)。但是ArduinoHTTPClient库WebSocketClient拒绝发送超过128字节的消息。Arduino从那一点开始就挂起了。 由于网络延迟,这意味着我不能每秒发送超过600字节的数据。 这种限制似乎是武断的,据我所见,并没有记录在案。使用下面的代码可

我有一台Arduino MKRNB 1500(具有LTE-M网络能力)。 我的代码使用websocket将消息上载到服务器。消息每秒上传一次,大约800-1000字节。我的websocket服务器接受这些消息(我已尝试使用浏览器客户端)。但是ArduinoHTTPClient库WebSocketClient拒绝发送超过128字节的消息。Arduino从那一点开始就挂起了。 由于网络延迟,这意味着我不能每秒发送超过600字节的数据。 这种限制似乎是武断的,据我所见,并没有记录在案。使用下面的代码可以很容易地复制它。由于LTE-M的网络延迟约为150毫秒,因此不能更频繁地发送较小的消息

如何发送更大的消息

#include <ArduinoHttpClient.h>
#include <MKRNB.h> //For LTE-M or NB-IOT connections
#include "arduino_secrets.h"

// initialize the LTE-M library instance
NBClient nbClient;
GPRS gprs;
NB nbAccess;
char server[] = "echo.websocket.org";  // server address
const char PINNUMBER[] = "0000";  //  = SIM SECRET_PINNUMBER;
int port = 80; // port 80 is the default for HTTP
WebSocketClient client = WebSocketClient(nbClient, server, port);

int count = 120;

void setup() {
  Serial.begin(9600);
  // LTE-M connection
  Serial.println(F("Connecting to LTE-M network"));
  boolean connected = false;
  while (!connected) {
    if ((nbAccess.begin(PINNUMBER) == NB_READY) &&
        (gprs.attachGPRS() == GPRS_READY)) {
      connected = true;
    } else {
      Serial.println("Not connected");
      delay(1000);
    }
  }
}

void loop() {
  Serial.println("starting WebSocket client");
  client.begin();

  while (client.connected() and count <= 1000) {
    Serial.print("Sending hello ");
    Serial.println(count);

    // send a hello #
    client.beginMessage(TYPE_TEXT);
    client.print(count);
    client.print(": ");
    int i = 0;
    while (i<= count){
      client.print("X");
      i++;
    }
    client.endMessage();

    // increment count for next message
    count++;

    // check if a message is available to be received
    int messageSize = client.parseMessage();

    if (messageSize > 0) {
      Serial.println("Received a message:");
      Serial.println(client.readString());
    }
    delay(1000);
  }

  Serial.println("disconnected");
}
#包括
#包括//用于LTE-M或NB-IOT连接
#包括“arduino_secrets.h”
//初始化LTE-M库实例
NBClient NBClient;
GPRS;
NB-NB访问;
char服务器[]=“echo.websocket.org”;//服务器地址
常量字符PINNUMBER[]=“0000”;//=SIM SECRET_PINNUMBER;
int端口=80;//端口80是HTTP的默认端口
WebSocketClient=WebSocketClient(nbClient、服务器、端口);
整数计数=120;
无效设置(){
Serial.begin(9600);
//LTE-M连接
Serial.println(F(“连接到LTE-M网络”);
布尔连接=假;
当(!已连接){
if((nbAccess.begin(PINNUMBER)=NB_READY)&&
(gprs.attachGPRS()==gprs\u READY)){
连接=真;
}否则{
Serial.println(“未连接”);
延迟(1000);
}
}
}
void循环(){
Serial.println(“启动WebSocket客户端”);
client.begin();

(client.connected()和count检查ArduinoHttpClient库后,发现WebSocketClient.h文件在第89行定义了一个有限的缓冲区:

uint8_t iTxBuffer[128];
我把它改成了

uint8_t iTxBuffer[4096];
问题解决了