MCPcopy Create free account
hub / github.com/Links2004/arduinoWebSockets

github.com/Links2004/arduinoWebSockets @2.7.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release 2.7.2 ↗ · + Follow
211 symbols 384 edges 31 files 82 documented · 39% updated 8d ago2.7.2 · 2025-12-20★ 2,056280 open issues

Browse by type

Functions 196 Types & classes 15
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

WebSocket Server and Client for Arduino Build Status

a WebSocket Server and Client for Arduino based on RFC6455.

Supported features of RFC6455
  • text frame
  • binary frame
  • connection close
  • ping
  • pong
  • continuation frame
Limitations
  • max input length is limited to the ram size and the WEBSOCKETS_MAX_DATA_SIZE define
  • max output length has no limit (the hardware is the limit)
  • Client send big frames with mask 0x00000000 (on AVR all frames)
  • continuation frame reassembly need to be handled in the application code

##### Limitations for Async ##### - Functions called from within the context of the websocket event might not honor yield() and/or delay(). See this issue for more info and a potential workaround. - wss / SSL is not possible.

Supported Hardware
  • ESP8266 Arduino for ESP8266
  • ESP32 Arduino for ESP32
  • ESP31B
  • Raspberry Pi Pico W Arduino for Pico
  • Particle with STM32 ARM Cortex M3
  • ATmega328 with Ethernet Shield (ATmega branch)
  • ATmega328 with enc28j60 (ATmega branch)
  • ATmega2560 with Ethernet Shield (ATmega branch)
  • ATmega2560 with enc28j60 (ATmega branch)
  • Arduino UNO R4 WiFi
  • Arduino Nano 33 IoT, MKR WIFI 1010 (requires WiFiNINA library)
  • Seeeduino XIAO, Seeeduino Wio Terminal (requires rpcWiFi library)
Note:

version 2.0.0 and up is not compatible with AVR/ATmega, check ATmega branch.

version 2.3.0 has API changes for the ESP8266 BareSSL (may brakes existing code)

Arduino for AVR not supports std namespace of c++.

wss / SSL

supported for: - wss client on the ESP8266 - wss / SSL for ESP32 in client mode - wss / SSL is not natively supported in WebSocketsServer however it is possible to achieve secure websockets by running the device behind an SSL proxy. See Nginx for a sample Nginx server configuration file to enable this.

Root CA Cert Bundles for SSL/TLS connections

Secure connections require the certificate of the server to be verified. One option is to provide a single certificate in the chain of trust. However, for flexibility and robustness, a certificate bundle is recommended. If a server changes the root CA from which it derives its certificates, this will not be a problem. With a single CA cert it will not connect.

Including a bundle with all CA certs will use 77.2 kB but this list can be reduced to 16.5 kB for the 41 most common. This results in 90% absolute usage coverage and 99% market share coverage according to W3Techs. The bundle is inserted into the compiled firmware. The bundle is not loaded into RAM, only its index.

ESP Async TCP

This libary can run in Async TCP mode on the ESP.

The mode can be activated in the WebSockets.h (see WEBSOCKETS_NETWORK_TYPE define).

ESPAsyncTCP libary is required.

High Level Client API

  • begin : Initiate connection sequence to the websocket host.
void begin(const char *host, uint16_t port, const char * url = "/", const char * protocol = "arduino");
void begin(String host, uint16_t port, String url = "/", String protocol = "arduino");
  • onEvent: Callback to handle for websocket events
 void onEvent(WebSocketClientEvent cbEvent);
  • WebSocketClientEvent: Handler for websocket events
 void (*WebSocketClientEvent)(WStype_t type, uint8_t * payload, size_t length)

Where WStype_t type is defined as:

  typedef enum {
      WStype_ERROR,
      WStype_DISCONNECTED,
      WStype_CONNECTED,
      WStype_TEXT,
      WStype_BIN,
      WStype_FRAGMENT_TEXT_START,
      WStype_FRAGMENT_BIN_START,
      WStype_FRAGMENT,
      WStype_FRAGMENT_FIN,
      WStype_PING,
      WStype_PONG,
  } WStype_t;

Issues

Submit issues to: https://github.com/Links2004/arduinoWebSockets/issues

License and credits

The library is licensed under LGPLv2.1

libb64 written by Chris Venter. It is distributed under Public Domain see LICENSE.

Core symbols most depended-on inside this repo

Shape

Method 147
Function 49
Class 15

Languages

C++76%
Python18%
C5%
TypeScript1%

Modules by API surface

src/WebSocketsClient.cpp32 symbols
src/WebSocketsServer.cpp31 symbols
src/SocketIOclient.cpp17 symbols
examples/esp8266_pico/WebSocketClientOTA/python_ota_server/main.py16 symbols
src/WebSockets.cpp15 symbols
examples/esp32_pio/CustomNetworkClient/src/network_client_secure.cpp14 symbols
examples/esp32_pio/WebSocketClientSSLBundle/gen_crt_bundle.py13 symbols
examples/esp32_pio/CustomNetworkClient/src/network_client.cpp10 symbols
src/WebSocketsServer.h7 symbols
examples/esp32_pio/WebSocketClientSSLBundle/src/main.cpp6 symbols
examples/esp32_pio/CustomNetworkClient/src/main.cpp6 symbols
examples/esp8266_pico/WebSocketServerHooked/ws-testclient.py5 symbols

For agents

$ claude mcp add arduinoWebSockets \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page