From 6283c13b61d09dd66a85d08ff90be38dd95a111a Mon Sep 17 00:00:00 2001 From: Rob Dobson Date: Sat, 24 Oct 2026 10:33:58 +0200 Subject: [PATCH] WebSocket: ask for 4000-byte file upload blocks The WebSocket channel asked for 500-byte blocks. The device's reply to ufStart decides the size: older firmware allows 800 on WebSocket, and firmware with PSRAM from 2026-10 (RaftWebServer PR #6) up to 16000. Bigger blocks are faster where storage is fast: 200 KB uploads to an SD card on an ESP32-S3 took 29 KB/s with 800-byte blocks and 52 KB/s with 4000. The device writes each block in its main loop, so 4000 keeps each write short (16000 was only a little faster). Co-Authored-By: Claude Opus 5.5 --- src/RaftChannelWebSocket.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/RaftChannelWebSocket.ts b/src/RaftChannelWebSocket.ts index 24a3187..09a047c 100644 --- a/src/RaftChannelWebSocket.ts +++ b/src/RaftChannelWebSocket.ts @@ -37,9 +37,12 @@ export default class RaftChannelWebSocket implements RaftChannel { // Conn event fn private _onConnEvent: RaftConnEventFn | null = null; - // File Handler parameters + // File Handler parameters - the device's reply to ufStart decides the block size (older firmware allows 800 bytes + // on WebSocket, firmware with PSRAM from 2026-10 up to 16000). Bigger blocks are faster where storage is fast + // (uploads to an SD card: 28 KB/s with 800 byte blocks, 43 with 4000) but the device writes each block in its main + // loop, so 4000 keeps each write short private _requestedBatchAckSize = 10; - private _requestedFileBlockSize = 500; + private _requestedFileBlockSize = 4000; fhBatchAckSize(): number { return this._requestedBatchAckSize; } fhFileBlockSize(): number { return this._requestedFileBlockSize; }