sending jpg through websocket from esp32 websocket client
Posted: Sun Jul 26, 2020 6:19 am
I playing with a ESP32-CAM.
I'm using the standard Windows installer for esp tools and esp-idf. So I'm using v4.0.1 from May 2020.
I have a image encoded as jpg in a struct as this
I want to send this image data across a websocket connection. Image size can be up to 300kB. The send function for binary data has the following syntax
On the server side I get no errors and can see some sort of data being received. But the ESP log tells me the websocket client is not behaving as expected::
I tried to replace portMAX_DELAY with 10000 as suggested here: https://github.com/espressif/esp-idf/issues/4316
But that did not remove the error message.
If I replace actual data length with 1000 I get no errors:
Any ideas what is going on? Am I supposed to split up the data in smaller chunks? I am currently assuming that any such fragmentation, if needed, is taken care of implicitly by the websocket API.
I'm using the standard Windows installer for esp tools and esp-idf. So I'm using v4.0.1 from May 2020.
I have a image encoded as jpg in a struct as this
Code: Select all
typedef struct {
uint8_t * buf; /*!< Pointer to the pixel data */
size_t len; /*!< Length of the buffer in bytes */
size_t width; /*!< Width of the buffer in pixels */
size_t height; /*!< Height of the buffer in pixels */
pixformat_t format; /*!< Format of the pixel data */
struct timeval timestamp; /*!< Timestamp since boot of the first DMA buffer of the frame */
} camera_fb_t;
I want to send this image data across a websocket connection. Image size can be up to 300kB. The send function for binary data has the following syntax
Code: Select all
esp_websocket_client_send(client,(char *)fb->buf, fb->len, portMAX_DELAY);
Code: Select all
E (26194) TRANSPORT_WS: Error transport_poll_write
E (26194) WEBSOCKET_CLIENT: Network error: esp_transport_write() returned 0, errno=0
But that did not remove the error message.
If I replace actual data length with 1000 I get no errors:
Code: Select all
esp_websocket_client_send(client,(char *)fb->buf, 1000, portMAX_DELAY);