Websocket connect doesn't work after converting to html by lv_web_emscripten


I developed an application by using LVGL, the application includes the function to connect the API server by websocket, the application calls the APIs provided by the libcurl library, all functions works well in simulator when compiling from C code.

When I converted the C code to a single html file by using lv_web_emscripten tool, the API server can’t be connected, “websocket connect failed” message is got。

Any comments or suggestion would be appreciated.

What MCU/Processor/Board and compiler are you using?


What LVGL version are you using?

LVGL v8.3.10

What do you want to achieve?

The generated HTML file can works well to connect to the JSON-RPC server.

What have you tried so far?

No idea about the root cause of the issue.

Code to reproduce

The following code is used to connect to the API server, the functions prefixed by curl_easy_ are provided by libcurl library. When converting to html file by lv_web_emscripten, the websocket doesn’t work anymore.

/* init and connect the websocket instance*/
CURL * websocket_connect(const char *ws_url)
CURL ws_curl;
CURLcode res;
#ifdef DEBUG
fprintf(stdout, “\nInit curl connection to %s\n”, ws_url);
ws_curl = curl_easy_init();
if (ws_curl == NULL)
fprintf(stderr, “ERROR: Failed to start a curl session.\n”);
message_display(“ERROR: Failed to start a curl session.\n”);
return NULL;
/set the ws link address`/
curl_easy_setopt(ws_curl, CURLOPT_URL, ws_url);
/set the websocket option: stop when connected to target server/
curl_easy_setopt(ws_curl, CURLOPT_CONNECT_ONLY, 2L);
Perform the request, res will get the return code */
res = curl_easy_perform(ws_curl);
if (res != CURLE_OK)
websocket_error(res, NULL);
return NULL;
return ws_curl;

Screenshot and/or video