Coder Social home page Coder Social logo

khoih-prog / websockets_generic Goto Github PK

View Code? Open in Web Editor NEW
88.0 7.0 21.0 2.03 MB

WebSocket / Socket.IO Server and Client for Arduino based on RFC6455. Now supporting Adafruit nRF52, Portenta_H7, STM32F/L/H/G/WB/MP1, Teensy, SAM DUE, SAMD21, SAMD51, Arduino SAMD21 (Nano 33 IoT), MKR1000 / MKR1010WiFi, RP2040-based boards using WiFi101, WiFiNINA, WiFi, Ethernet, WT32_ETH01, Teensy 4.1 NativeEthernet/QNEthernet or Portenta_H7 WiFi/Ethernet, etc. so that those boards can be voice-controlled by Alexa. Now supporting websocket only mode for Socket.IO. Ethernet_Generic library is used as default for W5x00

License: GNU General Public License v3.0

C 32.58% C++ 67.17% Shell 0.25%
nrf52 websockets websocket-server wifinina w5x00 esp8266 esp32 websocket-client wifi101 stm32

websockets_generic's Introduction

WebSockets_Generic Library

arduino-library-badge GitHub release GitHub contributions welcome GitHub issues

Donate to my libraries using BuyMeACoffee



Table of Contents



Important notes about Portenta_H7 Ethernet

Portenta_H7 Ethernet doesn't work in mbed_portenta core v3.0.0, and has been fixed in core v3.0.1. Check [Portenta_H7] Ethernet not working in core v3.0.0 #436.

Please use mbed_portenta core v2.8.0- or v3.0.1+ for Portenta_H7 Ethernet.



Why do we need this WebSockets_Generic library

Features

Many Web services require WebSockets library, which is so far written only for ESP8266/ESP32 boards. The ESP boards rely on this Markus Sattler's WebSockets Library to connect to Alexa via Sinric or SinricPro skills.

This WebSockets_Generic library is a RFC6455-based WebSocket Server and Client for Arduino boards. It is based on and modified from Markus Sattler's WebSockets Library to provide support to many more boards, such as WT32_ETH01 (ESP32 + LAN8720), Arduino SAMD21, Adafruit SAMD21/SAMD51, nRF52, STM32F/L/H/G/WB/MP1, Teensy, SAM DUE, RP2040-based boards, etc. and enable those boards to use WebSockets services, including voice-control Alexa along with Blynk. Those supported boards can also run WebSockets Server. The WebSockets can be used with ESP’s WiFi, WiFiNINA, WiFi101, W5x00, ENC28J60 Ethernet and Teensy 4.1 NativeEthernet/QNEthernet.

Supported features of RFC6455

  • text frame
  • binary frame
  • connection close
  • ping
  • pong
  • continuation frame

Important Notes

  1. Currently, the WebSocketServer feature is usable only for ESP8266/ESP32 (ESP32, ESP32_S2, ESP32_S3 and ESP32_C3) and WT32_ETH01 (ESP32 + LAN8720).
  2. The timeline when to fix and reintroduce the WebSocketServer feature to other boards is not determined yet.
  3. Please use the new WebSockets2_Generic Library if WebSocketServer is necessary. See Issue 2, Issue 3 and Issue 4

Currently supported Boards

This WebSockets_Generic library currently supports these following boards:

  1. nRF52 boards, such as AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense, Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B302_ublox, NINA_B112_ublox, etc.

  2. SAMD21

  • Arduino SAMD21: ZERO, MKRs, NANO_33_IOT, etc.
  • Adafruit SAMD21 (M0): ItsyBitsy M0, Feather M0, Feather M0 Express, Metro M0 Express, Circuit Playground Express, Trinket M0, PIRkey, Hallowing M0, Crickit M0, etc.
  • Seeeduino: LoRaWAN, Zero, Femto M0, XIAO M0, Wio GPS Board, etc.
  1. SAMD51
  • Adafruit SAMD51 (M4): Metro M4, Grand Central M4, ItsyBitsy M4, Feather M4 Express, Trellis M4, Metro M4 AirLift Lite, MONSTER M4SK Express, Hallowing M4, etc.
  • Seeeduino: Wio Terminal, Grove UI Wireless
  1. SAM DUE
  2. Teensy (4.1, 4.0, 3.6, 3.5, 3,2, 3.1, 3.0)
  3. STM32F/L/H/G/WB/MP1 boards (with 32+K Flash)
  • Nucleo-144
  • Nucleo-64
  • Discovery
  • Generic STM32F0, STM32F1, STM32F2, STM32F3, STM32F4, STM32F7 (with 64+K Flash): x8 and up
  • STM32L0, STM32L1, STM32L4
  • STM32G0, STM32G4
  • STM32H7
  • STM32WB
  • STM32MP1
  • LoRa boards
  • 3-D printer boards
  • Generic Flight Controllers
  • Midatronics boards
  1. ESP32
  • ESP32 boards, such as ESP32_DEV, etc.
  • ESP32_S2-based boards, such as ESP32S2_DEV, ESP32_S2 Saola, etc.
  • ESP32_C3-based boards, such as ESP32C3_DEV, etc. New
  • ESP32_S3 (ESP32S3_DEV, ESP32_S3_BOX, UM TINYS3, UM PROS3, UM FEATHERS3, etc.) New
  1. ESP8266

  2. RP2040-based boards, such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, using Arduino-mbed RP2040 v2.1.0+ core or Earle Philhower's arduino-pico core v1.5.1+.

  3. WT32_ETH01 boards using ESP32-based boards and LAN8720 Ethernet

  4. Portenta_H7 using either Murata WiFi or Vision-shield Ethernet

  5. RP2040-based boards, such as Nano_RP2040_Connect, RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040, using WiFiNINA or Ethernet

  6. RP2040W boards, such as RASPBERRY_PI_PICO_W, using Cyw43439 WiFi or Ethernet


Currently supported WiFi shields/modules

  1. WiFiNINA using WiFiNINA_Generic library
  2. WiFi101 using WiFi101_Generic library New
  3. U-Blox W101, W102 using WiFiNINA_Generic library
  4. ESP8266-AT command using WiFiEspAT library
  5. ESP8266/ESP32-AT command using ESP_AT_Lib library and ESP8266_AT_WebServer
  6. ESP32 and ESP8266 WiFi
  7. Portenta_H7 built-in Murata WiFi
  8. RP2040W built-in CYW43439 WiFi

Currently supported Ethernet shields/modules

  1. W5x00 using Ethernet_Generic library
  2. W5x00 using Ethernet, EthernetLarge, Ethernet2 or Ethernet3 library
  3. ENC28J60 using EthernetENC or UIPEthernet library
  4. LAN8720 Ethernet used in WT32_ETH01 boards
  5. LAN8742A or LAN8720 using STM32Ethernet and LwIP libraries.
  6. Teensy 4.1 built-in Ethernet using NativeEthernet library
  7. Teensy 4.1 built-in Ethernet using QNEthernet library
  8. Portenta_H7 using Ethernet from Portenta Vision shields



Prerequisites

  1. Arduino IDE 1.8.19+ for Arduino. GitHub release

  2. Arduino AVR core 1.8.6+ for Arduino (Use Arduino Board Manager) AVR boards. GitHub release

  3. Teensy core v1.57+ for Teensy (4.1, 4.0, 3.6, 3.5, 3,2, 3.1, 3.0) boards. GitHub release

  4. Arduino SAM DUE core v1.6.12+ for SAM DUE ARM Cortex-M3 boards.

  5. Arduino SAMD core 1.8.13+ for SAMD ARM Cortex-M0+ boards. GitHub release

  6. Adafruit SAMD core 1.7.11+ for SAMD ARM Cortex-M0+ and M4 boards (Nano 33 IoT, etc.). GitHub release

  7. Seeeduino SAMD core 1.8.3+ for SAMD21/SAMD51 boards (XIAO M0, Wio Terminal, etc.). Latest release

  8. Adafruit nRF52 v1.3.0+ for nRF52 boards such as Adafruit NRF52840_FEATHER, NRF52832_FEATHER, NRF52840_FEATHER_SENSE, NRF52840_ITSYBITSY, NRF52840_CIRCUITPLAY, NRF52840_CLUE, NRF52840_METRO, NRF52840_PCA10056, PARTICLE_XENON, NINA_B302_ublox, etc. GitHub release

  9. ESP32 Core 2.0.5+ for ESP32-based boards. Latest release

  10. ESP8266 Core 3.0.2+ for ESP8266-based boards. Latest release. To use ESP8266 core 2.7.1+ for LittleFS.

  11. ArduinoCore-mbed mbed_rp2040, mbed_nano, mbed_portenta core 3.4.1+ for Arduino (Use Arduino Board Manager) Portenta_H7, RP2040-based boards, such as Nano_RP2040_Connect, RASPBERRY_PI_PICO. GitHub release

  12. Earle Philhower's arduino-pico core v2.6.5+ for RP2040-based boards such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, etc. GitHub release

  13. Arduino Core for STM32 v2.3.0+ for STM32F/L/H/G/WB/MP1 boards. GitHub release. Use STM32 core v2.2.0 for LAN8720 or compile error.

  14. Arduino AmebaD core 3.1.4+ for Realtek RTL8720DN, RTL8722DM and RTL8722CSM. GitHub release

  15. WiFiNINA_Generic library v1.8.15-1+ if for WiFiNINA. To install. check arduino-library-badge.

  16. EthernetWebServer library v2.3.0+ if necessary to use Ethernet modules/shields. To install, check arduino-library-badge

  17. EthernetWebServer_STM32 library v1.5.0+ if necessary to use Ethernet modules/shields. To install, check arduino-library-badge

  18. WebServer_WT32_ETH01 library v1.5.1+ if necessary to use WT32_ETH01 boards. To install, check arduino-library-badge

  19. Depending on which Ethernet card you're using:

  1. WiFiWebServer library v1.10.1+ if necessary to use certain WiFi/WiFiNINA features. To install, check arduino-library-badge
  2. FlashStorage_SAMD library v1.3.2+ for SAMD21 and SAMD51 boards (ZERO, MKR, NANO_33_IOT, M0, M0 Pro, AdaFruit Itsy-Bitsy M4, etc.) if necessary to use certain features. GitHub release
  3. FlashStorage_STM32 library v1.2.0+ for STM32F/L/H/G/WB/MP1 boards. GitHub release if necessary to use certain features.
  4. DueFlashStorage library v1.0.0+ for SAM DUE if necessary to use certain features. To install, check arduino-library-badge.
  5. Adafruit's LittleFS/InternalFS for nRF52. Already included if you already installed Adafruit nRF52 board package from Boards Manager.
  6. DoubleResetDetector_Generic v1.8.1+ if necessary to use some examples. To install. check arduino-library-badge if necessary to use certain features.
  7. WiFi101_Generic Library v1.0.0+ to use SAMD MKR1000, etc. boards with WiFi101 to send large data. To install. check arduino-library-badge.
  8. SinricPro_Generic v2.8.5+ if necessary to use some examples. To install. check arduino-library-badge if necessary to use certain features.
  9. ESPAsyncTCP v1.2.2+ for ESP8266 Async.


Installation

Use Arduino Library Manager

The best and easiest way is to use Arduino Library Manager. Search for WebSockets_Generic, then select / install the latest version. You can also use this link arduino-library-badge for more detailed instructions.

Manual Install

Another way to install is to:

  1. Navigate to WebSockets_Generic page.
  2. Download the latest release WebSockets_Generic-master.zip.
  3. Extract the zip file to WebSockets_Generic-master directory
  4. Copy whole WebSockets_Generic-master folder to Arduino libraries' directory such as ~/Arduino/libraries/.

VS Code & PlatformIO:

  1. Install VS Code
  2. Install PlatformIO
  3. Install WebSockets_Generic library by using Library Manager. Search for WebSockets_Generic in Platform.io Author's Libraries
  4. Use included platformio.ini file from examples to ensure that all dependent libraries will installed automatically. Please visit documentation for the other options and examples at Project Configuration File


Packages' Patches

1. For Adafruit nRF52840 and nRF52832 boards

To be able to compile, run and automatically detect and display BOARD_NAME on nRF52840/nRF52832 boards, you have to copy the whole nRF52 Packages_Patches directory into Adafruit nRF52 directory (~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0).

Supposing the Adafruit nRF52 version is 1.3.0. These files must be copied into the directory:

  • ~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/platform.txt
  • ~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/boards.txt
  • ~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Udp.h
  • ~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Print.h
  • ~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Print.cpp
  • ~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/variants/NINA_B302_ublox/variant.h
  • ~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/variants/NINA_B302_ublox/variant.cpp
  • ~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/variants/NINA_B112_ublox/variant.h
  • ~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/variants/NINA_B112_ublox/variant.cpp
  • ~/.arduino15/packages/adafruit/hardware/nrf52/1.3.0/cores/nRF5/Udp.h

Whenever a new version is installed, remember to copy these files into the new version directory. For example, new version is x.yy.z These files must be copied into the directory:

  • ~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/platform.txt
  • ~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/boards.txt
  • ~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/cores/nRF5/Udp.h
  • ~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/cores/nRF5/Print.h
  • ~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/cores/nRF5/Print.cpp
  • ~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B302_ublox/variant.h
  • ~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B302_ublox/variant.cpp
  • ~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B112_ublox/variant.h
  • ~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B112_ublox/variant.cpp
  • ~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/cores/nRF5/Udp.h

2. For Teensy boards

To be able to compile and run on Teensy boards, you have to copy the files in Packages_Patches for Teensy directory into Teensy hardware directory (./arduino-1.8.19/hardware/teensy/avr/boards.txt).

Supposing the Arduino version is 1.8.19. These files must be copied into the directory:

  • ./arduino-1.8.19/hardware/teensy/avr/boards.txt
  • ./arduino-1.8.19/hardware/teensy/avr/cores/teensy/Stream.h
  • ./arduino-1.8.19/hardware/teensy/avr/cores/teensy3/Stream.h
  • ./arduino-1.8.19/hardware/teensy/avr/cores/teensy4/Stream.h

Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz These files must be copied into the directory:

  • ./arduino-x.yy.zz/hardware/teensy/avr/boards.txt
  • ./arduino-x.yy.zz/hardware/teensy/avr/cores/teensy/Stream.h
  • ./arduino-x.yy.zz/hardware/teensy/avr/cores/teensy3/Stream.h
  • ./arduino-x.yy.zz/hardware/teensy/avr/cores/teensy4/Stream.h

3. For Arduino SAM DUE boards

To be able to compile and run on SAM DUE boards, you have to copy the whole SAM DUE directory into Arduino sam directory (~/.arduino15/packages/arduino/hardware/sam/1.6.12).

Supposing the Arduino SAM core version is 1.6.12. This file must be copied into the directory:

  • ~/.arduino15/packages/arduino/hardware/sam/1.6.12/platform.txt

Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz This file must be copied into the directory:

  • ~/.arduino15/packages/arduino/hardware/sam/x.yy.zz/platform.txt

4. For Arduino SAMD boards

To be able to compile, run and automatically detect and display BOARD_NAME on Arduino SAMD (Nano-33-IoT, etc) boards, you have to copy the whole Arduino SAMD Packages_Patches directory into Arduino SAMD directory (~/.arduino15/packages/arduino/hardware/samd/1.8.13).

For core version v1.8.10+

Supposing the Arduino SAMD version is 1.8.13. Now only one file must be copied into the directory:

  • ~/.arduino15/packages/arduino/hardware/samd/1.8.13/platform.txt

Whenever a new version is installed, remember to copy this files into the new version directory. For example, new version is x.yy.zz

This file must be copied into the directory:

  • ~/.arduino15/packages/arduino/hardware/samd/x.yy.zz/platform.txt

For core version v1.8.9-

Supposing the Arduino SAMD version is 1.8.9. These files must be copied into the directory:

  • ~/.arduino15/packages/arduino/hardware/samd/1.8.9/platform.txt
  • ~/.arduino15/packages/arduino/hardware/samd/1.8.9/cores/arduino/Arduino.h

Whenever a new version is installed, remember to copy these files into the new version directory. For example, new version is x.yy.z

These files must be copied into the directory:

  • ~/.arduino15/packages/arduino/hardware/samd/x.yy.z/platform.txt
  • ~/.arduino15/packages/arduino/hardware/samd/x.yy.z/cores/arduino/Arduino.h

This is mandatory to fix the notorious Arduino SAMD compiler error. See Improve Arduino compatibility with the STL (min and max macro)

 ...\arm-none-eabi\include\c++\7.2.1\bits\stl_algobase.h:243:56: error: macro "min" passed 3 arguments, but takes just 2
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)

Whenever the above-mentioned compiler error issue is fixed with the new Arduino SAMD release, you don't need to copy the Arduino.h file anymore.

5. For Adafruit SAMD boards

To be able to compile, run and automatically detect and display BOARD_NAME on Adafruit SAMD (Itsy-Bitsy M4, etc) boards, you have to copy the whole Adafruit SAMD Packages_Patches directory into Adafruit samd directory (~/.arduino15/packages/adafruit/hardware/samd/1.7.11).

Supposing the Adafruit SAMD core version is 1.7.11. These files must be copied into the directory:

  • ~/.arduino15/packages/adafruit/hardware/samd/1.7.11/platform.txt
  • ~/.arduino15/packages/adafruit/hardware/samd/1.7.11/cores/arduino/Print.h
  • ~/.arduino15/packages/adafruit/hardware/samd/1.7.11/cores/arduino/Print.cpp

Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz These files must be copied into the directory:

  • ~/.arduino15/packages/adafruit/hardware/samd/x.yy.zz/platform.txt
  • ~/.arduino15/packages/adafruit/hardware/samd/x.yy.zz/cores/arduino/Print.h
  • ~/.arduino15/packages/adafruit/hardware/samd/x.yy.zz/cores/arduino/Print.cpp

6. For Seeeduino SAMD boards

To be able to compile, run and automatically detect and display BOARD_NAME on Seeeduino SAMD (XIAO M0, Wio Terminal, etc) boards, you have to copy the whole Seeeduino SAMD Packages_Patches directory into Seeeduino samd directory (~/.arduino15/packages/Seeeduino/hardware/samd/1.8.3).

Supposing the Seeeduino SAMD core version is 1.8.3. These files must be copied into the directory:

  • ~/.arduino15/packages/Seeeduino/hardware/samd/1.8.3/platform.txt
  • ~/.arduino15/packages/Seeeduino/hardware/samd/1.8.3/cores/arduino/Arduino.h
  • ~/.arduino15/packages/Seeeduino/hardware/samd/1.8.3/cores/arduino/Print.h
  • ~/.arduino15/packages/Seeeduino/hardware/samd/1.8.3/cores/arduino/Print.cpp

Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz These files must be copied into the directory:

  • ~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/platform.txt
  • ~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/cores/arduino/Arduino.h
  • ~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/cores/arduino/Print.h
  • ~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/cores/arduino/Print.cpp

7. For STM32 boards

7.1 For STM32 boards to use LAN8720

For Generic STM32F4 series boards, such as STM32F407VE, using LAN8720, please use STM32 core v2.2.0 as breaking core v2.3.0 creates the compile error.


To use LAN8720 on some STM32 boards

  • Nucleo-144 (F429ZI, NUCLEO_F746NG, NUCLEO_F746ZG, NUCLEO_F756ZG)
  • Discovery (DISCO_F746NG)
  • STM32F4 boards (BLACK_F407VE, BLACK_F407VG, BLACK_F407ZE, BLACK_F407ZG, BLACK_F407VE_Mini, DIYMORE_F407VGT, FK407M1)

you have to copy the files stm32f4xx_hal_conf_default.h and stm32f7xx_hal_conf_default.h into STM32 stm32 directory (~/.arduino15/packages/STM32/hardware/stm32/2.2.0/system) to overwrite the old files.

Supposing the STM32 stm32 core version is 2.2.0. These files must be copied into the directory:

  • ~/.arduino15/packages/STM32/hardware/stm32/2.2.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h for STM32F4.
  • ~/.arduino15/packages/STM32/hardware/stm32/2.2.0/system/STM32F7xx/stm32f7xx_hal_conf_default.h for Nucleo-144 STM32F7.

Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz, these files must be copied into the corresponding directory:

  • ~/.arduino15/packages/STM32/hardware/stm32/x.yy.zz/system/STM32F4xx/stm32f4xx_hal_conf_default.h
  • ~/.arduino15/packages/STM32/hardware/stm32/x.yy.zz/system/STM32F7xx/stm32f7xx_hal_conf_default.h

7.2 For STM32 boards to use Serial1

To use Serial1 on some STM32 boards without Serial1 definition (Nucleo-144 NUCLEO_F767ZI, Nucleo-64 NUCLEO_L053R8, etc.) boards, you have to copy the files STM32 variant.h into STM32 stm32 directory (~/.arduino15/packages/STM32/hardware/stm32/2.3.0). You have to modify the files corresponding to your boards, this is just an illustration how to do.

Supposing the STM32 stm32 core version is 2.3.0. These files must be copied into the directory:

  • ~/.arduino15/packages/STM32/hardware/stm32/2.3.0/variants/STM32F7xx/F765Z(G-I)T_F767Z(G-I)T_F777ZIT/NUCLEO_F767ZI/variant.h for Nucleo-144 NUCLEO_F767ZI.
  • ~/.arduino15/packages/STM32/hardware/stm32/2.3.0/variants/STM32L0xx/L052R(6-8)T_L053R(6-8)T_L063R8T/NUCLEO_L053R8/variant.h for Nucleo-64 NUCLEO_L053R8.

Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz, these files must be copied into the corresponding directory:

  • ~/.arduino15/packages/STM32/hardware/stm32/x.yy.zz/variants/STM32F7xx/F765Z(G-I)T_F767Z(G-I)T_F777ZIT/NUCLEO_F767ZI/variant.h
  • ~/.arduino15/packages/STM32/hardware/stm32/x.yy.zz/variants/STM32L0xx/L052R(6-8)T_L053R(6-8)T_L063R8T/NUCLEO_L053R8/variant.h

8. For RP2040-based boards using Earle Philhower arduino-pico core

8.1 To use BOARD_NAME

To be able to automatically detect and display BOARD_NAME on RP2040-based boards (RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040, GENERIC_RP2040, etc) boards, you have to copy the file RP2040 platform.txt into rp2040 directory (~/.arduino15/packages/rp2040/hardware/rp2040/1.4.0).

Supposing the rp2040 core version is 1.4.0. This file must be copied into the directory:

  • ~/.arduino15/packages/rp2040/hardware/rp2040/1.4.0/platform.txt

Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz This file must be copied into the directory:

  • ~/.arduino15/packages/rp2040/hardware/rp2040/x.yy.zz/platform.txt

With core after v1.5.0, this step is not necessary anymore thanks to the PR Add -DBOARD_NAME="{build.board}" #136.

8.2 To avoid compile error relating to microsecondsToClockCycles

Some libraries, such as Adafruit DHT-sensor-library, require the definition of microsecondsToClockCycles(). To be able to compile and run on RP2040-based boards, you have to copy the files in RP2040 Arduino.h into rp2040 directory (~/.arduino15/packages/rp2040/hardware/rp2040/1.4.0).

Supposing the rp2040 core version is 1.4.0. This file must be copied to replace:

  • ~/.arduino15/packages/rp2040/hardware/rp2040/1.4.0/cores/rp2040/Arduino.h

Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz This file must be copied to replace:

  • ~/.arduino15/packages/rp2040/hardware/rp2040/x.yy.zz/cores/rp2040/Arduino.h

With core after v1.5.0, this step is not necessary anymore thanks to the PR Add defs for compatibility #142.

9. For Portenta_H7 boards using Arduino IDE in Linux

To be able to upload firmware to Portenta_H7 using Arduino IDE in Linux (Ubuntu, etc.), you have to copy the file portenta_post_install.sh into mbed_portenta directory (~/.arduino15/packages/arduino/hardware/mbed_portenta/3.4.1/portenta_post_install.sh).

Then run the following command using sudo

$ cd ~/.arduino15/packages/arduino/hardware/mbed_portenta/3.4.1
$ chmod 755 portenta_post_install.sh
$ sudo ./portenta_post_install.sh

This will create the file /etc/udev/rules.d/49-portenta_h7.rules as follows:

# Portenta H7 bootloader mode UDEV rules

SUBSYSTEMS=="usb", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="035b", GROUP="plugdev", MODE="0666"

Supposing the ArduinoCore-mbed core version is 3.4.1. Now only one file must be copied into the directory:

  • ~/.arduino15/packages/arduino/hardware/mbed_portenta/3.4.1/portenta_post_install.sh

Whenever a new version is installed, remember to copy this files into the new version directory. For example, new version is x.yy.zz

This file must be copied into the directory:

  • ~/.arduino15/packages/arduino/hardware/mbed_portenta/x.yy.zz/portenta_post_install.sh

10. For RTL8720DN boards using AmebaD core

To avoid compile error relating to PROGMEM, you have to copy the file Realtek AmebaD core pgmspace.h into Realtek AmebaD directory (~/.arduino15/packages/realtek/hardware/AmebaD/3.1.4/cores/ambd/avr/pgmspace.h).

Supposing the Realtek AmebaD core version is 3.1.4. This file must be copied into the directory:

  • ~/.arduino15/packages/realtek/hardware/AmebaD/3.1.4/cores/ambd/avr/pgmspace.h

Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz This file must be copied into the directory:

  • ~/.arduino15/packages/realtek/hardware/AmebaD/x.yy.zz/cores/ambd/avr/pgmspace.h

11. For SAMD21 and SAMD51 boards using ArduinoCore-fab-sam core

To avoid compile error relating to SAMD21/SAMD51, you have to copy the file ArduinoCore-fab-sam core pgmspace.h into ArduinoCore-fab-sam samd directory (~/.arduino15/packages/Fab_SAM_Arduino/hardware/samd/1.9.0/boards.txt).

Supposing the ArduinoCore-fab-sam samd core version is 1.9.0. This file must be copied into the directory:

  • ~/.arduino15/packages/Fab_SAM_Arduino/hardware/samd/1.9.0/boards.txt

Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz This file must be copied into the directory:

  • ~/.arduino15/packages/Fab_SAM_Arduino/hardware/samd/x.yy.zz/boards.txt

12. For Seeeduino RP2040 boards

To be able to compile, run and automatically detect and display BOARD_NAME on Seeeduino RP2040 (XIAO RP2040, Wio RP2040 Mini) boards, you have to copy the whole Seeeduino RP2040 Packages_Patches directory into Seeeduino samd directory (~/.arduino15/packages/Seeeduino/hardware/rp2040/2.7.2).

Supposing the Seeeduino RP2040 core version is 2.7.2. These files must be copied into the directory:

  • ~/.arduino15/packages/Seeeduino/hardware/rp2040/2.7.2/boards.txt
  • ~/.arduino15/packages/Seeeduino/hardware/rp2040/2.7.2/variants/Seeed_XIAO_RP2040/pins_arduino.h

Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz These files must be copied into the directory:

  • ~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/boards.txt
  • ~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/variants/Seeed_XIAO_RP2040/pins_arduino.h

13. For Seeeduino nRF52840 boards

To be able to compile and run on Xiao nRF52840 boards, you have to copy the whole nRF52 1.0.0 directory into Seeeduino nRF52 directory (~/.arduino15/packages/Seeeduino/hardware/nrf52/1.0.0).

Supposing the Seeeduino nRF52 version is 1.0.0. These files must be copied into the directory:

  • ~/.arduino15/packages/Seeeduino/hardware/nrf52/1.0.0/platform.txt
  • ~/.arduino15/packages/Seeeduino/hardware/nrf52/1.0.0/cores/nRF5/Print.h
  • ~/.arduino15/packages/Seeeduino/hardware/nrf52/1.0.0/cores/nRF5/Print.cpp
  • ~/.arduino15/packages/Seeeduino/hardware/nrf52/1.0.0/cores/nRF5/Udp.h

Whenever a new version is installed, remember to copy these files into the new version directory. For example, new version is x.yy.z These files must be copied into the directory:

  • ~/.arduino15/packages/Seeeduino/hardware/nrf52/x.yy.z/platform.txt
  • ~/.arduino15/packages/Seeeduino/hardware/nrf52/x.yy.z/cores/nRF5/Print.h
  • ~/.arduino15/packages/Seeeduino/hardware/nrf52/x.yy.z/cores/nRF5/Print.cpp
  • ~/.arduino15/packages/Seeeduino/hardware/nrf52/x.yy.z/cores/nRF5/Udp.h


Libraries' Patches

1. For application requiring 2K+ HTML page

If your application requires 2K+ HTML page, the current Ethernet library must be modified if you are using W5200/W5500 Ethernet shields. W5100 is not supported for 2K+ buffer. If you use boards requiring different CS/SS pin for W5x00 Ethernet shield, for example ESP32, ESP8266, nRF52, etc., you also have to modify the following libraries to be able to specify the CS/SS pin correctly.

2. For Ethernet library

To fix Ethernet library, just copy these following files into the Ethernet library directory to overwrite the old files:

You can also use the forked and modified library at Patched Ethernet

3. For EthernetLarge library

To fix EthernetLarge library, just copy these following files into the EthernetLarge library directory to overwrite the old files:

You can also use the forked and modified library at Patched EthernetLarge

4. For Ethernet2 library

To fix Ethernet2 library, just copy these following files into the Ethernet2 library directory to overwrite the old files:

To add UDP Multicast support, necessary for the UPnP_Generic library:

You can also use the forked and modified library at Patched Ethernet2

5. For Ethernet3 library

  1. To fix Ethernet3 library, just copy these following files into the Ethernet3 library directory to overwrite the old files:

You can also use the forked and modified library at Patched Ethernet3

6. For UIPEthernet library

To be able to compile and run on nRF52 boards with ENC28J60 using UIPEthernet library, you have to copy these following files into the UIPEthernet utility directory to overwrite the old files:

7. For fixing ESP32 compile error

To fix ESP32 compile error, just copy the following file into the ESP32 cores/esp32 directory (e.g. ./arduino-1.8.19/hardware/espressif/cores/esp32) to overwrite the old file:

8. For fixing ESP8266 compile error

To fix ESP8266 compile error such as

error: 'class EthernetClass' has no member named 'init'
Ethernet.init (USE_THIS_SS_PIN);

just rename the following file in ./arduino-1.8.19/hardware/esp8266com/esp8266/libraries/Ethernet directory

  • From Ethernet.h to Ethernet_ESP8266.h


HOWTO Use analogRead() with ESP32 running WiFi and/or BlueTooth (BT/BLE)

Please have a look at ESP_WiFiManager Issue 39: Not able to read analog port when using the autoconnect example to have more detailed description and solution of the issue.

1. ESP32 has 2 ADCs, named ADC1 and ADC2

2. ESP32 ADCs functions

  • ADC1 controls ADC function for pins GPIO32-GPIO39
  • ADC2 controls ADC function for pins GPIO0, 2, 4, 12-15, 25-27

3.. ESP32 WiFi uses ADC2 for WiFi functions

Look in file adc_common.c

In ADC2, there're two locks used for different cases:

  1. lock shared with app and Wi-Fi: ESP32: When Wi-Fi using the ADC2, we assume it will never stop, so app checks the lock and returns immediately if failed. ESP32S2: The controller's control over the ADC is determined by the arbiter. There is no need to control by lock.

  2. lock shared between tasks: when several tasks sharing the ADC2, we want to guarantee all the requests will be handled. Since conversions are short (about 31us), app returns the lock very soon, we use a spinlock to stand there waiting to do conversions one by one.

adc2_spinlock should be acquired first, then adc2_wifi_lock or rtc_spinlock.

  • In order to use ADC2 for other functions, we have to acquire complicated firmware locks and very difficult to do
  • So, it's not advisable to use ADC2 with WiFi/BlueTooth (BT/BLE).
  • Use ADC1, and pins GPIO32-GPIO39
  • If somehow it's a must to use those pins serviced by ADC2 (GPIO0, 2, 4, 12, 13, 14, 15, 25, 26 and 27), use the fix mentioned at the end of ESP_WiFiManager Issue 39: Not able to read analog port when using the autoconnect example to work with ESP32 WiFi/BlueTooth (BT/BLE).


Important Notes

  1. Code is restructured to provide flexibility to make it easy to support many more WiFi/Ethernet modules/shields in the future. Please delete the *.cpp files, replaced by *.hpp files, in the src directory, if *.cpp files still exist after installing new version.

  2. For Adafruit nRF52, use the SPI's pin as follows:

  • SS/CS = 10
  • SPI_MOSI = MO(SI)
  • SPI_MISO = MI(SO)
  • SPI_SCK = SCK
  1. For Adafruit SAMD21/SAMD51, use the SPI's CS/SS pin as follows:
  • Itsy-Bitsy M0/M4, Feather M0 (Express), Hallowing M0 Express, Zero, Metro M0 => use CS = 16 = pin A2
  • Feather M4 (SAMD51) => use SS/CS = 9
  • Grand Central M4 => use SS/CS = 53
  • Hallowing M4 => use SS/CS = 10
  • Metro M4 AirLift => use SS/CS = 36

To know the default CS/SS pins of not listed boards, check the related variant.h files in

~/.arduino15/packages/adafruit/hardware/samd/x.y.zz/variants/board_name/variant.h

  1. For Arduino SAM DUE, use the SPI's pin as follows:



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.


wss / SS

supported for:

  • wss client on the ESP8266
  • 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.

ESP Async TCP

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

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

ESPAsyncTCP library is required.



How to use

In your code, select one of the currently supported network connection from the following list:

  1. NETWORK_ESP8266_ASYNC for ESP8266 Async
  2. NETWORK_W5100 for W5x00 Ethernet
  3. NETWORK_ENC28J60 for ENC28J60 Ethernet using UIPEthernet library
  4. NETWORK_ESP32 for ESP32 WiFi
  5. NETWORK_ESP32_ETH for ESP32 Ethernet
  6. NETWORK_WIFININA for WiFiNINA
  7. NETWORK_ETHERNET_ENC for ENC28J60 Ethernet using EthernetENC library
  8. NETWORK_RTL8720DN for NETWORK_RTL8720DN Ethernet using Seeed_Arduino_rpcWiFi and Seeed_Arduino_rpcUnified libraries
  9. NETWORK_NATIVEETHERNET for Teeensy 4.1 NativeEthernet
  10. NETWORK_LAN8742A for STM32 with LAN8742A Ethernet using STM32Ethernet library
  11. NETWORK_WIFI101 for SAMD_MKR1000 and SAMD_MKRWIFI1010 using WiFi101 library
  12. NETWORK_QN_ETHERNET for Teeensy 4.1 built-in Ethernet using QNEthernet Library
  13. NETWORK_PORTENTA_H7_WIFI for Portenta_H7 using Murata WiFi
  14. NETWORK_PORTENTA_H7_ETHERNET for Portenta_H7 using Vision-shield Ethernet
  15. NETWORK_ESP32_ASYNC for ESP32 using Async WebSockets
  16. NETWORK_RP2040W_WIFI RP2040W using CYW43439 WiFi with arduino-pico core

then add #define WEBSOCKETS_NETWORK_TYPE before #include <WebSocketsClient_Generic.h>

For example:

#define WEBSOCKETS_NETWORK_TYPE   NETWORK_WIFININA

#include <WebSocketsClient_Generic.h>

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");
void begin(IPAddress host, uint16_t port, const char * url = "/", const char * protocol = "arduino");

void begin(IPAddress host, uint16_t port, String url = "/", String protocol = "arduino");
  • beginSSL : Initiate SSL connection sequence to the WebSocket host.
#if defined(HAS_SSL)
#ifdef SSL_AXTLS

  void beginSSL(const char * host, uint16_t port, const char * url = "/", const char * fingerprint = "", const char * protocol = "arduino");
  void beginSSL(IPAddress host, uint16_t port, String url = "/", String fingerprint = "", String protocol = "arduino");
  void beginSSL(String host, uint16_t port, String url = "/", String fingerprint = "", String protocol = "arduino");

#else

  void beginSSL(const char * host, uint16_t port, const char * url = "/", const uint8_t * fingerprint = NULL, const char * protocol = "arduino");
  void beginSSL(IPAddress host, uint16_t port, String url = "/", String fingerprint = "", String protocol = "arduino");   
  void beginSslWithCA(const char * host, uint16_t port, const char * url = "/", BearSSL::X509List * CA_cert = NULL, const char * protocol = "arduino");

#endif    // SSL_AXTLS

  void beginSslWithCA(const char * host, uint16_t port, const char * url = "/", const char * CA_cert = NULL, const char * protocol = "arduino");

#endif    // HAS_SSL
  • beginSocketIO : Initiate connection sequence to the WebSocketIO host.
void beginSocketIO(const char * host, uint16_t port, const char * url = "/socket.io/?EIO=3", const char * protocol = "arduino");
void beginSocketIO(String host, uint16_t port, String url = "/socket.io/?EIO=3", String protocol = "arduino");

void beginSocketIO(IPAddress host, uint16_t port, String url = "/socket.io/?EIO=3", 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;

Configure SIO_PING_INTERVAL, SIO_PONG_TIMEOUT and SIO_DISCONNECT_TIMEOUT_COUNT

//////////////////////////////
// New in v2.16.0
#define SIO_PING_INTERVAL                     90000L
#define SIO_PONG_TIMEOUT                      120000L
#define SIO_DISCONNECT_TIMEOUT_COUNT          10

//////////////////////////////


Examples

For Generic boards using W5x00 Ethernet shield

  1. Generic_WebSocketClientSocketIO_W5500
  2. Generic_WebSocketClientStompOverSockJs_W5500
  3. Generic_WebSocketClientStomp_W5500
  4. Generic_WebSocketClient_W5500.
  5. Generic_WebSocketServerAllFunctionsDemo_W5500
  6. Generic_WebSocketServerFragmentation_W5500
  7. Generic_WebSocketServerHttpHeaderValidation_W5500
  8. Generic_WebSocketServer_LEDcontrol_W5500
  9. Generic_WebSocketServer_W5500

For Generic boards using WiFiNINA

  1. Generic_WebSocketClientSocketIO_WiFiNINA
  2. Generic_WebSocketClientStompOverSockJs_WiFiNINA
  3. Generic_WebSocketClientStomp_WiFiNINA
  4. Generic_WebSocketClient_WiFiNINA.
  5. Generic_WebSocketServerAllFunctionsDemo_WiFiNINA
  6. Generic_WebSocketServerFragmentation_WiFiNINA
  7. Generic_WebSocketServerHttpHeaderValidation_WiFiNINA
  8. Generic_WebSocketServer_LEDcontrol_WiFiNINA
  9. Generic_WebSocketServer_WiFiNINA
  10. Generic_WebSocketClientSSL_WiFiNINA.

For Generic boards using ENC28J60 Ethernet shield and EthernetENC library

  1. Generic_WebSocketClientSocketIO_EthernetENC
  2. Generic_WebSocketClientStompOverSockJs_EthernetENC
  3. Generic_WebSocketClientStomp_EthernetENC
  4. Generic_WebSocketClient_EthernetENC.
  5. Generic_WebSocketServerAllFunctionsDemo_EthernetENC
  6. Generic_WebSocketServerFragmentation_EthernetENC
  7. Generic_WebSocketServerHttpHeaderValidation_EthernetENC
  8. Generic_WebSocketServer_LEDcontrol_EthernetENC
  9. Generic_WebSocketServer_EthernetENC

For WiFiNINA

  1. WebSocketClient_NINA.
  2. WebSocketClientSocketIO_NINA
  3. WebSocketClientStomp_NINA
  4. WebSocketClientStompOverSockJs_NINA
  5. WebSocketClientSSL_NINA
  6. WebSocketClient_Sticky_SocketIO_NINA. New

For WiFi101

  1. WebSocketClient_WiFi101.
  2. WebSocketClientSocketIO_WiFi101
  3. WebSocketClientStomp_WiFi101
  4. WebSocketClientStompOverSockJs_WiFi101
  5. WebSocketClientSSL_WiFi101.

For W5x00 Ethernet shield

  1. WebSocketClient_W5500.
  2. WebSocketClientSocketIO_W5500
  3. WebSocketClientStomp_W5500
  4. WebSocketClientStompOverSockJs_W5500
  5. WebSocketClient_Sticky_SocketIO_W5500. New

For ENC28J60 Ethernet shield using UIPEthernet library

  1. WebSocketClient_ENC.
  2. WebSocketClientSocketIO_ENC
  3. WebSocketClientStomp_ENC
  4. WebSocketClientStompOverSockJs_ENC

For ESP32 board

  1. ESP32_WebSocketClient
  2. ESP32_WebSocketClientSocketIO New
  3. ESP32_WebSocketClientSSL
  4. ESP32_WebSocketServer

For ESP8266 board

  1. ESP8266_WebSocketClient.
  2. ESP8266_WebSocketClientSocketIO
  3. ESP8266_WebSocketClientSocketIOack
  4. ESP8266_WebSocketClientSSL.
  5. ESP8266_WebSocketClientStomp
  6. ESP8266_WebSocketClientStompOverSockJs
  7. ESP8266_WebSocketServer
  8. ESP8266_WebSocketServerAllFunctionsDemo
  9. ESP8266_WebSocketServerFragmentation
  10. ESP8266_WebSocketServerHttpHeaderValidation
  11. ESP8266_WebSocketServer_LEDcontrol
  12. ESP8266_WebSocketClient_Sticky_SocketIO New
  13. ESP8266_WebSocketClientOTA New

For SeeedStudio WIO Terminal using Realtek RTL8720DN WiFi

  1. WIOTerminal_WebSocketClient
  2. WIOTerminal_WebSocketClientSSL.
  3. WIOTerminal_WebSocketServer

For STM32 boards using built-in LAN8742A Ethernet

  1. STM32_WebSocketClient_LAN8742A
  2. STM32_WebSocketClientSocketIO_LAN8742A
  3. STM32_WebSocketClientStomp_LAN8742A
  4. STM32_WebSocketClientStompOverSockJs_LAN8742A
  5. STM32_WebSocketServerAllFunctionsDemo_LAN8742A
  6. STM32_WebSocketServerFragmentation_LAN8742A
  7. STM32_WebSocketServerHttpHeaderValidation_LAN8742A
  8. STM32_WebSocketServer_LAN8742A
  9. STM32_WebSocketServer_LEDcontrol_LAN8742A

For Teensy boards using ENC28J60 Ethernet shield and EthernetENC library

  1. Teensy_WebSocketClientSocketIO_EthernetENC
  2. Teensy_WebSocketClientStompOverSockJs_EthernetENC
  3. Teensy_WebSocketClientStomp_EthernetENC
  4. Teensy_WebSocketClient_EthernetENC.
  5. Teensy_WebSocketServerAllFunctionsDemo_EthernetENC
  6. Teensy_WebSocketServerFragmentation_EthernetENC
  7. Teensy_WebSocketServerHttpHeaderValidation_EthernetENC
  8. Teensy_WebSocketServer_LEDcontrol_EthernetENC
  9. Teensy_WebSocketServer_EthernetENC

For Teensy 4.1 boards using NativeEthernet

  1. Teensy_WebSocketClient_NativeEthernet
  2. Teensy_WebSocketClientStompOverSockJs_NativeEthernet
  3. Teensy_WebSocketClientStomp_NativeEthernet
  4. Teensy_WebSocketClient_NativeEthernet.
  5. Teensy_WebSocketServerAllFunctionsDemo_NativeEthernet
  6. Teensy_WebSocketServerFragmentation_NativeEthernet
  7. Teensy_WebSocketServerHttpHeaderValidation_NativeEthernet
  8. Teensy_WebSocketServer_LEDcontrol_NativeEthernet
  9. Teensy_WebSocketServer_NativeEthernet

For Teensy boards using W5x00 Ethernet shield

  1. Teensy_WebSocketClientSocketIO_W5500
  2. Teensy_WebSocketClientStompOverSockJs_W5500
  3. Teensy_WebSocketClientStomp_W5500
  4. Teensy_WebSocketClient_W5500.
  5. Teensy_WebSocketServerAllFunctionsDemo_W5500
  6. Teensy_WebSocketServerFragmentation_W5500
  7. Teensy_WebSocketServerHttpHeaderValidation_W5500
  8. Teensy_WebSocketServer_LEDcontrol_W5500
  9. Teensy_WebSocketServer_W5500

For Teensy boards using WiFiNINA

  1. Teensy_WebSocketClientSocketIO_WiFiNINA
  2. Teensy_WebSocketClientStompOverSockJs_WiFiNINA
  3. Teensy_WebSocketClientStomp_WiFiNINA
  4. Teensy_WebSocketClient_WiFiNINA.
  5. Teensy_WebSocketServerAllFunctionsDemo_WiFiNINA
  6. Teensy_WebSocketServerFragmentation_WiFiNINA
  7. Teensy_WebSocketServerHttpHeaderValidation_WiFiNINA
  8. Teensy_WebSocketServer_LEDcontrol_WiFiNINA
  9. Teensy_WebSocketServer_WiFiNINA
  10. Teensy_WebSocketClientSSL_WiFiNINA.

For Teensy 4.1 boards using QNEthernet

  1. Teensy_WebSocketClient_QNEthernet
  2. Teensy_WebSocketClientSocketIO_QNEthernet
  3. Teensy_WebSocketServerAllFunctionsDemo_QNEthernet
  4. Teensy_WebSocketServerFragmentation_QNEthernet
  5. Teensy_WebSocketServerHttpHeaderValidation_QNEthernet
  6. Teensy_WebSocketServer_LEDcontrol_QNEthernet
  7. Teensy_WebSocketServer_QNEthernet

Nodejs Socket.IO Test Server to use with examples

  1. app.js
  2. SIO_server.sh
  3. HOWTO.md
  4. package.json
  5. package-lock.json

Nodejs_Sticky_SocketIO_TestServer to use with examples

  1. Multi_Sticky_SIO.js
  2. Multi_Sticky_SIO_server.sh
  3. HOWTO.md
  4. package.json
  5. package-lock.json

For WT32_ETH01 board

  1. WT32_ETH01_WebSocketClient.
  2. WT32_ETH01_WebSocketClientSocketIO
  3. WT32_ETH01_WebSocketClientSSL
  4. WT32_ETH01_WebSocketServer
  5. WT32_ETH01_WebSocketClient_Sticky_SocketIO. New
  6. WT32_ETH01_SSL_SIO. New

For Portenta_H7 board

Portenta_Ethernet
  1. Portenta_H7_WebSocketClient.
  2. Portenta_H7_WebSocketClientSocketIO
  3. Portenta_H7_WebSocketClient_Sticky_SocketIO. New
WiFi
  1. WebSocketClientSocketIO_WiFi
  2. WebSocketClient_WiFi
  3. WebSocketClient_Sticky_SocketIO_WiFi. New

For ESP8266 Async WebSocket

  1. ESP8266_AsyncWSClient New

For RP2040W boards using built-in WiFi

  1. WebSocketClient_RP2040W
  2. WebSocketClientSocketIO_RP2040W
  3. WebSocketClientSSL_RP2040W
  4. WebSocketClient_Sticky_SocketIO_RP2040W


#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) )
// Default pin 10 to SS/CS
#define USE_THIS_SS_PIN 10
#define BOARD_TYPE "SAM DUE"
#elif ( defined(CORE_TEENSY) )
#error You have to use examples written for Teensy
#endif
#ifndef BOARD_NAME
#define BOARD_NAME BOARD_TYPE
#endif
#define _WEBSOCKETS_LOGLEVEL_ 2
#define WEBSOCKETS_NETWORK_TYPE NETWORK_WIFININA
#include <WebSocketsClient_Generic.h>
WebSocketsClient webSocket;
#define USE_SSL false
#if USE_SSL
// Deprecated echo.websocket.org to be replaced
#define WS_SERVER "wss://echo.websocket.org"
#define WS_PORT 443
#else
// To run a local WebSocket Server
#define WS_SERVER "192.168.2.30"
#define WS_PORT 8080
#endif
int status = WL_IDLE_STATUS;
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
char ssid[] = "your_ssid"; // your network SSID (name)
char pass[] = "12345678"; // your network password (use for WPA, or use as key for WEP), length must be 8+
bool alreadyConnected = false;
void webSocketEvent(const WStype_t& type, uint8_t * payload, const size_t& length)
{
switch (type)
{
case WStype_DISCONNECTED:
if (alreadyConnected)
{
Serial.println("[WSc] Disconnected!");
alreadyConnected = false;
}
break;
case WStype_CONNECTED:
{
alreadyConnected = true;
Serial.print("[WSc] Connected to url: ");
Serial.println((char *) payload);
// send message to server when Connected
webSocket.sendTXT("Connected");
}
break;
case WStype_TEXT:
Serial.print("[WSc] get text: ");
Serial.println((char *) payload);
// send message to server
// webSocket.sendTXT("message here");
break;
case WStype_BIN:
Serial.print("[WSc] get binary length: ");
Serial.println(length);
// KH, To check
// hexdump(payload, length);
// send data to server
webSocket.sendBIN(payload, length);
break;
case WStype_PING:
// pong will be send automatically
Serial.println("[WSc] get ping");
break;
case WStype_PONG:
// answer to a ping we send
Serial.println("[WSc] get pong");
break;
default:
break;
}
}
void printWifiStatus()
{
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
// print your board's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("WebSockets Client @ IP Address: ");
Serial.println(ip);
// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print("signal strength (RSSI):");
Serial.print(rssi);
Serial.println(" dBm");
}
void setup()
{
// Serial.begin(921600);
Serial.begin(115200);
while (!Serial);
Serial.print("\nStart Generic_WebSocketClient_WiFiNINA on "); Serial.println(BOARD_NAME);
Serial.println(WEBSOCKETS_GENERIC_VERSION);
Serial.println("Used/default SPI pinout:");
Serial.print("MOSI:");
Serial.println(MOSI);
Serial.print("MISO:");
Serial.println(MISO);
Serial.print("SCK:");
Serial.println(SCK);
Serial.print("SS:");
Serial.println(SS);
// check for the WiFi module:
if (WiFi.status() == WL_NO_MODULE)
{
Serial.println("Communication with WiFi module failed!");
// don't continue
while (true);
}
String fv = WiFi.firmwareVersion();
if (fv < WIFI_FIRMWARE_LATEST_VERSION)
{
Serial.println("Please upgrade the firmware");
}
// attempt to connect to Wifi network:
while (status != WL_CONNECTED)
{
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.begin(ssid, pass);
// wait 10 seconds for connection:
//delay(10000);
}
printWifiStatus();
// server address, port and URL
Serial.print("WebSockets Server : ");
Serial.println(WS_SERVER);
// server address, port and URL
#if USE_SSL
webSocket.beginSSL(WS_SERVER, WS_PORT);
#else
webSocket.begin(WS_SERVER, WS_PORT, "/");
#endif
// event handler
webSocket.onEvent(webSocketEvent);
// use HTTP Basic Authorization this is optional remove if not needed
//webSocket.setAuthorization("user", "Password");
// try ever 5000 again if connection has failed
webSocket.setReconnectInterval(5000);
// start heartbeat (optional)
// ping server every 15000 ms
// expect pong from server within 3000 ms
// consider connection disconnected if pong is not received 2 times
webSocket.enableHeartbeat(15000, 3000, 2);
// server address, port and URL
Serial.print("Connected to WebSockets Server @ ");
Serial.println(WS_SERVER);
}
void loop()
{
webSocket.loop();
}



Debug Terminal Output Samples

Start Generic_WebSocketClient_EthernetENC on NRF52840_FEATHER
WebSockets_Generic v2.16.1
[WS] Board : NRF52840_FEATHER , setCsPin: 10
[WS] Default SPI pinout:
[WS] MOSI: 25
[WS] MISO: 24
[WS] SCK: 26
[WS] SS: 5
[WS] =========================
WebSockets Client @ IP address: 192.168.2.93
Connecting to WebSockets Server @ IP address: 192.168.2.140
[WS] [WS-Client][handleHeader] RX: HTTP/1.1 101 Switching Protocols
[WS] [WS-Client][handleHeader] RX: Server: arduino-WebSocketsServer
[WS] [WS-Client][handleHeader] RX: Upgrade: websocket
[WS] [WS-Client][handleHeader] RX: Connection: Upgrade
[WS] [WS-Client][handleHeader] RX: Sec-WebSocket-Version: 13
[WS] [WS-Client][handleHeader] RX: Sec-WebSocket-Accept: PJIpSp/QBZPtgaA5LIeNbtWz710=
[WS] [WS-Client][handleHeader] RX: Sec-WebSocket-Protocol: arduino
[WS] [WS-Client][handleHeader] Header read fin.
[WS] [WS-Client][handleHeader] Client settings:
[WS] [WS-Client][handleHeader] - cURL: /
[WS] [WS-Client][handleHeader] - cKey: XAtxzzeVt0HiQZ3cu85Y3A==
[WS] [WS-Client][handleHeader] Server header:
[WS] [WS-Client][handleHeader] - cCode: 101
[WS] [WS-Client][handleHeader] - cIsUpgrade: 1
[WS] [WS-Client][handleHeader] - cIsWebsocket: 1
[WS] [WS-Client][handleHeader] - cAccept: PJIpSp/QBZPtgaA5LIeNbtWz710=
[WS] [WS-Client][handleHeader] - cProtocol: arduino
[WS] [WS-Client][handleHeader] - cExtensions: 
[WS] [WS-Client][handleHeader] - cVersion: 13
[WS] [WS-Client][handleHeader] - cSessionId: 
[WSc] Connected to url: /
[WSc] get text: Connected

2. Generic_Ethernet_Blinds on NRF52840_FEATHER with ENC28J60 using EthernetENC Library

You can see the NRF52840_FEATHER board, with ENC28J60 using EthernetENC Library, connects to SinricPro service using SinricPro_Generic library.

It also uses this WebSockets_Generic library to communicate with SinricPro service, to control Blinds via the Sinric Pro phone APP

Starting Generic_Ethernet_Blinds on NRF52840_FEATHER with ENC28J60 using EthernetENC Library
[SRP] =========================
[SRP] Default SPI pinout:
[SRP] MOSI: 25
[SRP] MISO: 24
[SRP] SCK: 26
[SRP] SS: 5
[SRP] =========================
[SRP] Use default CS/SS pin :  10
Index = 6
Connected!
[Ethernet]: IP-Address is 192.168.2.97
[SRP] Creating new device. No current DeviceId = 123456789012345678901234
[SRP] add(): Adding DeviceId = 123456789012345678901234
[SRP] begin(): App-Key = 12345678-1234-1234-1234-123456789012
[SRP] begin(): App-Secret = 12345678-1234-1234-1234-123456789012-12345678-1234-1234-1234-123456789012
[SRP] Websocket: Connecting to WebSocket Server:  ws.sinric.pro
Websocket: headers:
appkey:12345678-1234-1234-1234-123456789012
deviceids:123456789012345678901234
restoredevicestates:false
platform:NRF52840_FEATHER
version:2.8.4
Connected to SinricPro
[SRP] handleReceiveQueue(): Message(s) in receiveQueue = 1
[SRP] handleReceiveQueue(): Valid Signature. Processing message...
[SRP] extractTimestamp(): Got Timestamp = 1602031564
[SRP] handleReceiveQueue(): Message(s) in receiveQueue = 1
[SRP] handleReceiveQueue(): Valid Signature. Processing message...
[SRP] extractTimestamp(): Got Timestamp = 1602031575
[SRP] handleRequest(): handling request
{
  "header": {
    "payloadVersion": 2,
    "signatureVersion": 1
  },
  "payload": {
    "action": "setPowerState",
    "clientId": "sinricpro-web",
    "createdAt": 1602031575,
    "deviceAttributes": [],
    "deviceId": "123456789012345678901234",
    "replyToken": "4a2080b4-ca92-4fb7-aec1-3aa8d108a818",
    "type": "request",
    "value": {
      "state": "Off"
    }
  },
  "signature": {
    "HMAC": "PttsGuF4w4xfwzJHA6C5WDOmQmBgHXv9eTMSg8hYHXM="
  }
}
Device 123456789012345678901234 power turned off
[SRP] handleSendQueue(): Sending Number of Message(s) in sendQueue = 1
{
  "header": {
    "payloadVersion": 2,
    "signatureVersion": 1
  },
  "payload": {
    "action": "setPowerState",
    "clientId": "sinricpro-web",
    "createdAt": 1602031575,
    "deviceId": "123456789012345678901234",
    "message": "OK",
    "replyToken": "4a2080b4-ca92-4fb7-aec1-3aa8d108a818",
    "success": true,
    "type": "response",
    "value": {
      "state": "Off"
    }
  },
  "signature": {
    "HMAC": "42vn7js8X+KvuHHPZSrGeJt7dtwP8VVl9Y3cZsYtXOA="
  }
}
[SRP] handleSendQueue: Sending to WebSocket
[SRP] handleSendQueue(): Message sent.
[SRP] handleReceiveQueue(): Message(s) in receiveQueue = 1
[SRP] handleReceiveQueue(): Valid Signature. Processing message...
[SRP] extractTimestamp(): Got Timestamp = 1602031577
[SRP] handleRequest(): handling request
{
  "header": {
    "payloadVersion": 2,
    "signatureVersion": 1
  },
  "payload": {
    "action": "setPowerState",
    "clientId": "sinricpro-web",
    "createdAt": 1602031577,
    "deviceAttributes": [],
    "deviceId": "123456789012345678901234",
    "replyToken": "81a2433d-957d-481e-a9f7-2dea5c2e6c78",
    "type": "request",
    "value": {
      "state": "On"
    }
  },
  "signature": {
    "HMAC": "ir18LAhlUVCWHY5hA8QdGY8bzHE/s4XBeX8cwHTaPQI="
  }
}
Device 123456789012345678901234 power turned on
[SRP] handleSendQueue(): Sending Number of Message(s) in sendQueue = 1
{
  "header": {
    "payloadVersion": 2,
    "signatureVersion": 1
  },
  "payload": {
    "action": "setPowerState",
    "clientId": "sinricpro-web",
    "createdAt": 1602031577,
    "deviceId": "123456789012345678901234",
    "message": "OK",
    "replyToken": "81a2433d-957d-481e-a9f7-2dea5c2e6c78",
    "success": true,
    "type": "response",
    "value": {
      "state": "On"
    }
  },
  "signature": {
    "HMAC": "9Z1uVUjeaCf1T2Ol6Fv4wXkz8gaJvEYmmIRfRcDnOgA="
  }
}
[SRP] handleSendQueue: Sending to WebSocket
[SRP] handleSendQueue(): Message sent.
[SRP] handleReceiveQueue(): Message(s) in receiveQueue = 1
[SRP] handleReceiveQueue(): Valid Signature. Processing message...
[SRP] extractTimestamp(): Got Timestamp = 1602031578
[SRP] handleRequest(): handling request
{
  "header": {
    "payloadVersion": 2,
    "signatureVersion": 1
  },
  "payload": {
    "action": "setRangeValue",
    "clientId": "sinricpro-web",
    "createdAt": 1602031578,
    "deviceAttributes": [],
    "deviceId": "123456789012345678901234",
    "replyToken": "16d6fd59-dfd1-4017-ab51-ff8bb85fc806",
    "type": "request",
    "value": {
      "rangeValue": 100
    }
  },
  "signature": {
    "HMAC": "KfAwQ6z5XGvoZaspBVBP+CXnryW0YsEILqyxesHDhJo="
  }
}
Device 123456789012345678901234 set position to 100
[SRP] handleSendQueue(): Sending Number of Message(s) in sendQueue = 1
{
  "header": {
    "payloadVersion": 2,
    "signatureVersion": 1
  },
  "payload": {
    "action": "setRangeValue",
    "clientId": "sinricpro-web",
    "createdAt": 1602031578,
    "deviceId": "123456789012345678901234",
    "message": "OK",
    "replyToken": "16d6fd59-dfd1-4017-ab51-ff8bb85fc806",
    "success": true,
    "type": "response",
    "value": {
      "rangeValue": 100
    }
  },
  "signature": {
    "HMAC": "CNYG9Or+ZH+R2S1Ouvd2bqX8lT/8Siu23T8LycZVtTk="
  }
}
[SRP] handleSendQueue: Sending to WebSocket
[SRP] handleSendQueue(): Message sent.
[SRP] handleReceiveQueue(): Message(s) in receiveQueue = 1
[SRP] handleReceiveQueue(): Valid Signature. Processing message...
[SRP] extractTimestamp(): Got Timestamp = 1602031579
[SRP] handleRequest(): handling request
{
  "header": {
    "payloadVersion": 2,
    "signatureVersion": 1
  },
  "payload": {
    "action": "setRangeValue",
    "clientId": "sinricpro-web",
    "createdAt": 1602031579,
    "deviceAttributes": [],
    "deviceId": "123456789012345678901234",
    "replyToken": "864b1a6b-d539-49e0-bad8-48fa27d80d7f",
    "type": "request",
    "value": {
      "rangeValue": 0
    }
  },
  "signature": {
    "HMAC": "8CsQ57297F9lzrKBopsE8Xga2RdT9pgJpA8moGQFBTs="
  }
}
Device 123456789012345678901234 set position to 0
[SRP] handleSendQueue(): Sending Number of Message(s) in sendQueue = 1
{
  "header": {
    "payloadVersion": 2,
    "signatureVersion": 1
  },
  "payload": {
    "action": "setRangeValue",
    "clientId": "sinricpro-web",
    "createdAt": 1602031579,
    "deviceId": "123456789012345678901234",
    "message": "OK",
    "replyToken": "864b1a6b-d539-49e0-bad8-48fa27d80d7f",
    "success": true,
    "type": "response",
    "value": {
      "rangeValue": 0
    }
  },
  "signature": {
    "HMAC": "AF7bO1deIYIh3VLvVuLaRx6n1ACVYgk2Evl3NgiZ0pg="
  }
}
[SRP] handleSendQueue: Sending to WebSocket
[SRP] handleSendQueue(): Message sent.

3. WebSocketClientSocketIO_W5500 on NRF52840_FEATHER with W5500 using Ethernet_Generic Library

Start WebSocketClientSocketIO_W5500 on NRF52840_FEATHER with W5x00 using Ethernet_Generic Library
WebSockets_Generic v2.16.1
[WS] Board : NRF52840_FEATHER , setCsPin: 10
[WS] Default SPI pinout:
[WS] MOSI: 25
[WS] MISO: 24
[WS] SCK: 26
[WS] SS: 5
[WS] =========================
WebSockets Client @ IP address: 192.168.2.108
Connecting to WebSockets Server @ IP address: 192.168.2.30, port: 8080
["event_name",{"now":6671}]
[WS] [WS-Client][handleHeader] RX: HTTP/1.1 200 OK
[WS] [WS-Client][handleHeader] RX: Content-Type: text/plain; charset=UTF-8
[WS] [WS-Client][handleHeader] RX: Content-Length: 103
[WS] [WS-Client][handleHeader] RX: Access-Control-Allow-Credentials: true
[WS] [WS-Client][handleHeader] RX: Access-Control-Allow-Origin: file://
[WS] [WS-Client][handleHeader] RX: Set-Cookie: io=ivB-kiMefQhNrlkgAAAd; Path=/; HttpOnly; SameSite=Strict
[WS] [WS-Client][handleHeader] RX: Date: Thu, 08 Oct 2020 00:32:59 GMT
[WS] [WS-Client][handleHeader] RX: Connection: keep-alive
[WS] [WS-Client][handleHeader] RX: Keep-Alive: timeout=5
[WS] [WS-Client][handleHeader] Header read fin.
[WS] [WS-Client][handleHeader] Client settings:
[WS] [WS-Client][handleHeader] - cURL: /socket.io/?EIO=3
[WS] [WS-Client][handleHeader] - cKey: DT1hYS8BbVNsE++xI7B82A==
[WS] [WS-Client][handleHeader] Server header:
[WS] [WS-Client][handleHeader] - cCode: 200
[WS] [WS-Client][handleHeader] - cIsUpgrade: 0
[WS] [WS-Client][handleHeader] - cIsWebsocket: 1
[WS] [WS-Client][handleHeader] - cAccept: 
[WS] [WS-Client][handleHeader] - cProtocol: arduino
[WS] [WS-Client][handleHeader] - cExtensions: 
[WS] [WS-Client][handleHeader] - cVersion: 0
[WS] [WS-Client][handleHeader] - cSessionId: ivB-kiMefQhNrlkgAAAd
[IOc] Disconnected
[WS] [WS-Client][handleHeader] RX: HTTP/1.1 200 OK
[WS] [WS-Client][handleHeader] RX: Content-Type: text/plain; charset=UTF-8
[WS] [WS-Client][handleHeader] RX: Content-Length: 103
[WS] [WS-Client][handleHeader] RX: Access-Control-Allow-Credentials: true
[WS] [WS-Client][handleHeader] RX: Access-Control-Allow-Origin: file://
[WS] [WS-Client][handleHeader] RX: Set-Cookie: io=Lq1IQW-WBtymSZzzAAAe; Path=/; HttpOnly; SameSite=Strict
[WS] [WS-Client][handleHeader] RX: Date: Thu, 08 Oct 2020 00:32:59 GMT
[WS] [WS-Client][handleHeader] RX: Connection: keep-alive
[WS] [WS-Client][handleHeader] RX: Keep-Alive: timeout=5
[WS] [WS-Client][handleHeader] Header read fin.
[WS] [WS-Client][handleHeader] Client settings:
[WS] [WS-Client][handleHeader] - cURL: /socket.io/?EIO=3
[WS] [WS-Client][handleHeader] - cKey: onWidNpa6PhedJSy60Az5A==
[WS] [WS-Client][handleHeader] Server header:
[WS] [WS-Client][handleHeader] - cCode: 200
[WS] [WS-Client][handleHeader] - cIsUpgrade: 0
[WS] [WS-Client][handleHeader] - cIsWebsocket: 0
[WS] [WS-Client][handleHeader] - cAccept: 
[WS] [WS-Client][handleHeader] - cProtocol: arduino
[WS] [WS-Client][handleHeader] - cExtensions: 
[WS] [WS-Client][handleHeader] - cVersion: 0
[WS] [WS-Client][handleHeader] - cSessionId: Lq1IQW-WBtymSZzzAAAe
[WS] [WS-Client][handleHeader] RX: HTTP/1.1 101 Switching Protocols
[WS] [WS-Client][handleHeader] RX: Upgrade: websocket
[WS] [WS-Client][handleHeader] RX: Connection: Upgrade
[WS] [WS-Client][handleHeader] RX: Sec-WebSocket-Accept: 92pjBGiagarYGjMy1FsUcKOzrSk=
[WS] [WS-Client][handleHeader] RX: Sec-WebSocket-Protocol: arduino
[WS] [WS-Client][handleHeader] Header read fin.
[WS] [WS-Client][handleHeader] Client settings:
[WS] [WS-Client][handleHeader] - cURL: /socket.io/?EIO=3
[WS] [WS-Client][handleHeader] - cKey: i6rJQeEER2+zCTjRW4OjLg==
[WS] [WS-Client][handleHeader] Server header:
[WS] [WS-Client][handleHeader] - cCode: 101
[WS] [WS-Client][handleHeader] - cIsUpgrade: 1
[WS] [WS-Client][handleHeader] - cIsWebsocket: 1
[WS] [WS-Client][handleHeader] - cAccept: 92pjBGiagarYGjMy1FsUcKOzrSk=
[WS] [WS-Client][handleHeader] - cProtocol: arduino
[WS] [WS-Client][handleHeader] - cExtensions: 
[WS] [WS-Client][handleHeader] - cVersion: 0
[WS] [WS-Client][handleHeader] - cSessionId: Lq1IQW-WBtymSZzzAAAe
[IOc] Connected to url: /socket.io/?EIO=3

4. Generic_WebSocketClientSocketIO_EthernetENC on NRF52840_FEATHER with ENC28J60 using EthernetENC Library

Start Generic_WebSocketClientSocketIO_EthernetENC on NRF52840_FEATHER with ENC28J60 using EthernetENC Library
WebSockets_Generic v2.16.1
[WS] Board : NRF52840_FEATHER , setCsPin: 10
[WS] Default SPI pinout:
[WS] MOSI: 25
[WS] MISO: 24
[WS] SCK: 26
[WS] SS: 5
[WS] =========================
WebSockets Client @ IP address: 192.168.2.86
Connecting to WebSockets Server @ IP address: 192.168.2.30, port: 8080
["event_name",{"now":9577}]
[WS] [WS-Client][handleHeader] RX: HTTP/1.1 200 OK
[WS] [WS-Client][handleHeader] RX: Content-Type: text/plain; charset=UTF-8
[WS] [WS-Client][handleHeader] RX: Content-Length: 103
[WS] [WS-Client][handleHeader] RX: Access-Control-Allow-Credentials: true
[WS] [WS-Client][handleHeader] RX: Access-Control-Allow-Origin: file://
[WS] [WS-Client][handleHeader] RX: Set-Cookie: io=W5HMvbfTz5Nbn2SgAAAV; Path=/; HttpOnly; SameSite=Strict
[WS] [WS-Client][handleHeader] RX: Date: Thu, 08 Oct 2020 00:23:11 GMT
[WS] [WS-Client][handleHeader] RX: Connection: keep-alive
[WS] [WS-Client][handleHeader] RX: Keep-Alive: timeout=5
[WS] [WS-Client][handleHeader] Header read fin.
[WS] [WS-Client][handleHeader] Client settings:
[WS] [WS-Client][handleHeader] - cURL: /socket.io/?EIO=3
[WS] [WS-Client][handleHeader] - cKey: tTIoy547t0bFK6IwotJ0Ww==
[WS] [WS-Client][handleHeader] Server header:
[WS] [WS-Client][handleHeader] - cCode: 200
[WS] [WS-Client][handleHeader] - cIsUpgrade: 0
[WS] [WS-Client][handleHeader] - cIsWebsocket: 1
[WS] [WS-Client][handleHeader] - cAccept: 
[WS] [WS-Client][handleHeader] - cProtocol: arduino
[WS] [WS-Client][handleHeader] - cExtensions: 
[WS] [WS-Client][handleHeader] - cVersion: 0
[WS] [WS-Client][handleHeader] - cSessionId: W5HMvbfTz5Nbn2SgAAAV
[IOc] Disconnected
[WS] [WS-Client][handleHeader] RX: HTTP/1.1 200 OK
[WS] [WS-Client][handleHeader] RX: Content-Type: text/plain; charset=UTF-8
[WS] [WS-Client][handleHeader] RX: Content-Length: 103
[WS] [WS-Client][handleHeader] RX: Access-Control-Allow-Credentials: true
[WS] [WS-Client][handleHeader] RX: Access-Control-Allow-Origin: file://
[WS] [WS-Client][handleHeader] RX: Set-Cookie: io=r1Kx0T7wZNQ9BHk9AAAW; Path=/; HttpOnly; SameSite=Strict
[WS] [WS-Client][handleHeader] RX: Date: Thu, 08 Oct 2020 00:23:11 GMT
[WS] [WS-Client][handleHeader] RX: Connection: keep-alive
[WS] [WS-Client][handleHeader] RX: Keep-Alive: timeout=5
[WS] [WS-Client][handleHeader] Header read fin.
[WS] [WS-Client][handleHeader] Client settings:
[WS] [WS-Client][handleHeader] - cURL: /socket.io/?EIO=3
[WS] [WS-Client][handleHeader] - cKey: BgGmlEiRrKzeEDEHHE48qA==
[WS] [WS-Client][handleHeader] Server header:
[WS] [WS-Client][handleHeader] - cCode: 200
[WS] [WS-Client][handleHeader] - cIsUpgrade: 0
[WS] [WS-Client][handleHeader] - cIsWebsocket: 0
[WS] [WS-Client][handleHeader] - cAccept: 
[WS] [WS-Client][handleHeader] - cProtocol: arduino
[WS] [WS-Client][handleHeader] - cExtensions: 
[WS] [WS-Client][handleHeader] - cVersion: 0
[WS] [WS-Client][handleHeader] - cSessionId: r1Kx0T7wZNQ9BHk9AAAW
[WS] [WS-Client][handleHeader] RX: HTTP/1.1 101 Switching Protocols
[WS] [WS-Client][handleHeader] RX: Upgrade: websocket
[WS] [WS-Client][handleHeader] RX: Connection: Upgrade
[WS] [WS-Client][handleHeader] RX: Sec-WebSocket-Accept: P76KK/oGpRX1UE1cAtk5jp31+Aw=
[WS] [WS-Client][handleHeader] RX: Sec-WebSocket-Protocol: arduino
[WS] [WS-Client][handleHeader] Header read fin.
[WS] [WS-Client][handleHeader] Client settings:
[WS] [WS-Client][handleHeader] - cURL: /socket.io/?EIO=3
[WS] [WS-Client][handleHeader] - cKey: 1uSPYGC/Asnl0DfyQcW5NQ==
[WS] [WS-Client][handleHeader] Server header:
[WS] [WS-Client][handleHeader] - cCode: 101
[WS] [WS-Client][handleHeader] - cIsUpgrade: 1
[WS] [WS-Client][handleHeader] - cIsWebsocket: 1
[WS] [WS-Client][handleHeader] - cAccept: P76KK/oGpRX1UE1cAtk5jp31+Aw=
[WS] [WS-Client][handleHeader] - cProtocol: arduino
[WS] [WS-Client][handleHeader] - cExtensions: 
[WS] [WS-Client][handleHeader] - cVersion: 0
[WS] [WS-Client][handleHeader] - cSessionId: r1Kx0T7wZNQ9BHk9AAAW
[IOc] Connected to url: /socket.io/?EIO=3

5. WIOTerminal_WebSocketClientSSL on SeeedStudio SAMD51 WIO_TERMINAL with Realtek RTL8720DN WiFi using Seeed_Arduino_rpcWiFi Library

Start WIOTerminal_WebSocketClientSSL on WIO_TERMINAL
WebSockets_Generic v2.16.1
WebSockets Client started @ IP address: 192.168.2.150
WebSockets Server : wss://account.duckdns.org
Connected to WebSockets Server @ wss://account.duckdns.org
[WS] [WS-Client] Connect wss...
[WS] [WS-Client] Calling _client.tcp->connect, _host = wss://account.duckdns.org , port = 443
[WS] [WS-Client] Calling _client.tcp->connect, _connectResult = 1
[WS] [WS-Client] connectedCb
[WS] [WS-Client][connectedCb] Connected to Host: wss://account.duckdns.org , Port: 443
[WS] [WS-Client] [sendHeader] Sending header...
[WS] [WS-Client] [sendHeader] Handshake: GET / HTTP/1.1
Host: wss://account.duckdns.org:443
Connection: Upgrade
Upgrade: websocket
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: SfXbpj+U4TexBeIDuBiYog==
Sec-WebSocket-Protocol: arduino
Origin: file://
User-Agent: arduino-WebSocket-Client

6. Generic_WebSocketClientSSL_WiFiNINA on Arduino SAMD21 Nano-33-IoT with WiFiNINA using WiFiNINA_Generic Library

Start Generic_WebSocketClientSSL_WiFiNINA on SAMD_NANO_33_IOT
WebSockets_Generic v2.16.1
Used/default SPI pinout:
MOSI:11
MISO:12
SCK:13
SS:10
Attempting to connect to SSID: HueNet1
SSID: HueNet1
WebSockets Client @ IP Address: 192.168.2.98
signal strength (RSSI):-13 dBm
WebSockets Server : wss://account.duckdns.org
Connected to WebSockets Server @ wss://account.duckdns.org
[WS] [WS-Client] Connect wss...
[WS] [WS-Client] connectedCb
[WS] [WS-Client][connectedCb] Connected to Host: wss://account.duckdns.org , Port: 443
[WS] [WS-Client] [sendHeader] Sending header...
[WS] [WS-Client] [sendHeader] Handshake: GET / HTTP/1.1
Host: wss://account.duckdns.org:443
Connection: Upgrade
Upgrade: websocket
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: XOexobdyHBCcAnl9W4F+9w==
Sec-WebSocket-Protocol: arduino
Origin: file://
User-Agent: arduino-WebSocket-Client

7. WebSocketClientSocketIO_NINA on Arduino SAMD21 Nano-33-IoT with WiFiNINA using WiFiNINA_Generic Library

7.1 Client

Start WebSocketClientSocketIO_NINA on SAMD_NANO_33_IOT
WebSockets_Generic v2.16.1
Used/default SPI pinout:
MOSI:11
MISO:12
SCK:13
SS:10
Attempting to connect to SSID: HueNet1
SSID: HueNet1
WebSockets Client IP Address: 192.168.2.114
signal strength (RSSI):-18 dBm
Connecting to WebSockets Server @ IP address: 192.168.2.30, port: 8080
[WS] WebSockets_Generic v2.16.1
[WS] [wsIOc] found EIO=4 disable EIO ping on client
[WS] [WS-Client] Connect ws...
[WS] [WS-Client][connectedCb] Connected to Host:192.168.2.30, Port:8080
[WS] [WS-Client] [sendHeader] Sending header...
[WS] sendHeader: client->cKey = 7nb1qwQBvz58aozmAyBmag==
[WS] [WS-Client] [sendHeader] Handshake:GET /socket.io/?EIO=4&transport=polling HTTP/1.1
Host: 192.168.2.30:8080
Connection: keep-alive
Origin: file://
User-Agent: arduino-WebSocket-Client
[WS] [WS-Client] [sendHeader] Sending header... Done (us):2669
[WS] [WS-Client][handleHeader] RX:HTTP/1.1 200 OK
[WS] [WS-Client][handleHeader] RX:Content-Type: text/plain; charset=UTF-8
[WS] [WS-Client][handleHeader] RX:Content-Length: 97
[WS] [WS-Client][handleHeader] RX:Date: Mon, 24 May 2021 02:19:53 GMT
[WS] [WS-Client][handleHeader] RX:Connection: keep-alive
[WS] [WS-Client][handleHeader] Header read fin.
[WS] [WS-Client][handleHeader] Client settings:
[WS] [WS-Client][handleHeader] - cURL:/socket.io/?EIO=4
[WS] [WS-Client][handleHeader] - cKey:7nb1qwQBvz58aozmAyBmag==
[WS] [WS-Client][handleHeader] Server header:
[WS] [WS-Client][handleHeader] - cCode:200
[WS] [WS-Client][handleHeader] - cIsUpgrade:0
[WS] [WS-Client][handleHeader] - cIsWebsocket:1
[WS] [WS-Client][handleHeader] - cAccept:
[WS] [WS-Client][handleHeader] - cProtocol:arduino
[WS] [WS-Client][handleHeader] - cExtensions:
[WS] [WS-Client][handleHeader] - cVersion:0
[WS] [WS-Client][handleHeader] - cSessionId:
[WS] [WS-Client][handleHeader] Still missing cSessionId try Socket.IO
[WS] [WS-Client][handleHeader] socket.io json: 0{"sid":"WdrsvWrSeNmPDSlFAAAa","upgrades":["websocket"],"pingInterval":25000,"pingTimeout":20000}
[WS] [WS-Client][handleHeader] - cSessionId: WdrsvWrSeNmPDSlFAAAa
[WS] [WS-Client][handleHeader] Header read fin.
[WS] [WS-Client][handleHeader] Client settings:
[WS] [WS-Client][handleHeader] - cURL:/socket.io/?EIO=4
[WS] [WS-Client][handleHeader] - cKey:7nb1qwQBvz58aozmAyBmag==
[WS] [WS-Client][handleHeader] Server header:
[WS] [WS-Client][handleHeader] - cCode:200
[WS] [WS-Client][handleHeader] - cIsUpgrade:0
[WS] [WS-Client][handleHeader] - cIsWebsocket:1
[WS] [WS-Client][handleHeader] - cAccept:
[WS] [WS-Client][handleHeader] - cProtocol:arduino
[WS] [WS-Client][handleHeader] - cExtensions:
[WS] [WS-Client][handleHeader] - cVersion:0
[WS] [WS-Client][handleHeader] - cSessionId:WdrsvWrSeNmPDSlFAAAa
[WS] [WS-Client][handleHeader] found cSessionId
[WS] [WS-Client] [sendHeader] Sending header...
[WS] sendHeader: client->cKey = 6b1sIaeSY4sl6HQqSLZaKQ==
[WS] [WS-Client] [sendHeader] Handshake:GET /socket.io/?EIO=4&transport=websocket&sid=WdrsvWrSeNmPDSlFAAAa HTTP/1.1
Host: 192.168.2.30:8080
Connection: Upgrade
Upgrade: websocket
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: 6b1sIaeSY4sl6HQqSLZaKQ==
Sec-WebSocket-Protocol: arduino
Origin: file://
User-Agent: arduino-WebSocket-Client
[WS] [WS-Client] [sendHeader] Sending header... Done (us):3458
[WS] [WS-Client][handleHeader] RX:HTTP/1.1 101 Switching Protocols
[WS] [WS-Client][handleHeader] RX:Upgrade: websocket
[WS] [WS-Client][handleHeader] RX:Connection: Upgrade
[WS] [WS-Client][handleHeader] RX:Sec-WebSocket-Accept: KJjOfxcGJBEkOTLzz/+pFRXs0Bc=
[WS] [WS-Client][handleHeader] RX:Sec-WebSocket-Protocol: arduino
[WS] [WS-Client][handleHeader] Header read fin.
[WS] [WS-Client][handleHeader] Client settings:
[WS] [WS-Client][handleHeader] - cURL:/socket.io/?EIO=4
[WS] [WS-Client][handleHeader] - cKey:6b1sIaeSY4sl6HQqSLZaKQ==
[WS] [WS-Client][handleHeader] Server header:
[WS] [WS-Client][handleHeader] - cCode:101
[WS] [WS-Client][handleHeader] - cIsUpgrade:1
[WS] [WS-Client][handleHeader] - cIsWebsocket:1
[WS] [WS-Client][handleHeader] - cAccept:KJjOfxcGJBEkOTLzz/+pFRXs0Bc=
[WS] [WS-Client][handleHeader] - cProtocol:arduino
[WS] [WS-Client][handleHeader] - cExtensions:
[WS] [WS-Client][handleHeader] - cVersion:0
[WS] [WS-Client][handleHeader] - cSessionId:WdrsvWrSeNmPDSlFAAAa
[WS] [WS-Client][handleHeader] Websocket connection init done.
[WS] [wsIOc] Connected to url:/socket.io/?EIO=4
[IOc] Connected to url: /socket.io/?EIO=4
[WS] [wsIOc] get pong
[IOc] Get PONG
[WS] [wsIOc] connected: len = 30
[WS] [wsIOc] data: {"sid":"QPel_hhsFl5pJ9ZpAAAb"}
["event_name",{"now":30001}]
[WS] [wsIOc] get ping send pong:3
[IOc] Get PING
[WS] [WS-Client] Sending HB ping
["event_name",{"now":30001}]

7.2 Server

Using the Socket.IO Server in Nodejs_SocketIO_TestServer

kh@kh-Inspiron-3593:~/Downloads/Nodejs/New_SIO$ nodejs app
Server launched on port 8080
Connected
QPel_hhsFl5pJ9ZpAAAb
JWT token test:  { host: '192.168.2.30:8080',
  connection: 'keep-alive',
  origin: 'file://',
  'user-agent': 'arduino-WebSocket-Client' }
Message from Client :  { now: 30001 }

8. Generic_WebSocketClientSocketIO_W5500 on NRF52840_FEATHER with W5x00 using Ethernet_Generic Library

8.1 Client

Start Generic_WebSocketClientSocketIO_W5500 on NRF52840_FEATHER with W5x00 using Ethernet_Generic Library
WebSockets_Generic v2.16.1
[WS] Board :NRF52840_FEATHER, setCsPin:10
[WS] Default SPI pinout:
[WS] MOSI:25
[WS] MISO:24
[WS] SCK:26
[WS] SS:5
[WS] =========================
_pinCS = 0
W5100 init, using SS_PIN_DEFAULT = 10, new ss_pin = 10, W5100Class::ss_pin = 10
W5100::init: W5500, SSIZE =8192
WebSockets Client @ IP address: 192.168.2.94
Connecting to WebSockets Server @ IP address: 192.168.2.30, port: 8080
[WS] WebSockets_Generic v2.16.1
[WS] [wsIOc] found EIO=4 disable EIO ping on client
[WS] [WS-Client][connectedCb] Connected to Host:192.168.2.30, Port:8080
[WS] [WS-Client] [sendHeader] Sending header...
[WS] sendHeader: client->cKey = A5uXYZ6TvNkcNshB9bd4mw==
[WS] [WS-Client] [sendHeader] Handshake:GET /socket.io/?EIO=4&transport=polling HTTP/1.1
Host: 192.168.2.30:8080
Connection: keep-alive
Authorization: 1234567890
User-Agent: arduino-WebSocket-Client
[WS] [WS-Client] [sendHeader] Sending header... Done (us):1953
[WS] [WS-Client][handleHeader] RX:HTTP/1.1 200 OK
[WS] [WS-Client][handleHeader] RX:Content-Type: text/plain; charset=UTF-8
[WS] [WS-Client][handleHeader] RX:Content-Length: 97
[WS] [WS-Client][handleHeader] RX:Date: Mon, 24 May 2021 02:44:22 GMT
[WS] [WS-Client][handleHeader] RX:Connection: keep-alive
[WS] [WS-Client][handleHeader] Header read fin.
[WS] [WS-Client][handleHeader] Client settings:
[WS] [WS-Client][handleHeader] - cURL:/socket.io/?EIO=4
[WS] [WS-Client][handleHeader] - cKey:A5uXYZ6TvNkcNshB9bd4mw==
[WS] [WS-Client][handleHeader] Server header:
[WS] [WS-Client][handleHeader] - cCode:200
[WS] [WS-Client][handleHeader] - cIsUpgrade:0
[WS] [WS-Client][handleHeader] - cIsWebsocket:1
[WS] [WS-Client][handleHeader] - cAccept:
[WS] [WS-Client][handleHeader] - cProtocol:arduino
[WS] [WS-Client][handleHeader] - cExtensions:
[WS] [WS-Client][handleHeader] - cVersion:0
[WS] [WS-Client][handleHeader] - cSessionId:
[WS] [WS-Client][handleHeader] Still missing cSessionId try Socket.IO
[WS] [WS-Client][handleHeader] socket.io json: 0{"sid":"NsqUuXlPnVoCSumYAAAc","upgrades":["websocket"],"pingInterval":25000,"pingTimeout":20000}
[WS] [WS-Client][handleHeader] - cSessionId: NsqUuXlPnVoCSumYAAAc
[WS] [WS-Client][handleHeader] Header read fin.
[WS] [WS-Client][handleHeader] Client settings:
[WS] [WS-Client][handleHeader] - cURL:/socket.io/?EIO=4
[WS] [WS-Client][handleHeader] - cKey:A5uXYZ6TvNkcNshB9bd4mw==
[WS] [WS-Client][handleHeader] Server header:
[WS] [WS-Client][handleHeader] - cCode:200
[WS] [WS-Client][handleHeader] - cIsUpgrade:0
[WS] [WS-Client][handleHeader] - cIsWebsocket:1
[WS] [WS-Client][handleHeader] - cAccept:
[WS] [WS-Client][handleHeader] - cProtocol:arduino
[WS] [WS-Client][handleHeader] - cExtensions:
[WS] [WS-Client][handleHeader] - cVersion:0
[WS] [WS-Client][handleHeader] - cSessionId:NsqUuXlPnVoCSumYAAAc
[WS] [WS-Client][handleHeader] found cSessionId
[WS] [WS-Client] [sendHeader] Sending header...
[WS] sendHeader: client->cKey = sQfvRYgeBW4Lg9NMIB977g==
[WS] [WS-Client] [sendHeader] Handshake:GET /socket.io/?EIO=4&transport=websocket&sid=NsqUuXlPnVoCSumYAAAc HTTP/1.1
Host: 192.168.2.30:8080
Connection: Upgrade
Upgrade: websocket
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: sQfvRYgeBW4Lg9NMIB977g==
Sec-WebSocket-Protocol: arduino
Authorization: 1234567890
User-Agent: arduino-WebSocket-Client
[WS] [WS-Client] [sendHeader] Sending header... Done (us):3907
[WS] [WS-Client][handleHeader] RX:HTTP/1.1 101 Switching Protocols
[WS] [WS-Client][handleHeader] RX:Upgrade: websocket
[WS] [WS-Client][handleHeader] RX:Connection: Upgrade
[WS] [WS-Client][handleHeader] RX:Sec-WebSocket-Accept: KSsqUKjgfa1vum+jM9GAEuTogmY=
[WS] [WS-Client][handleHeader] RX:Sec-WebSocket-Protocol: arduino
[WS] [WS-Client][handleHeader] Header read fin.
[WS] [WS-Client][handleHeader] Client settings:
[WS] [WS-Client][handleHeader] - cURL:/socket.io/?EIO=4
[WS] [WS-Client][handleHeader] - cKey:sQfvRYgeBW4Lg9NMIB977g==
[WS] [WS-Client][handleHeader] Server header:
[WS] [WS-Client][handleHeader] - cCode:101
[WS] [WS-Client][handleHeader] - cIsUpgrade:1
[WS] [WS-Client][handleHeader] - cIsWebsocket:1
[WS] [WS-Client][handleHeader] - cAccept:KSsqUKjgfa1vum+jM9GAEuTogmY=
[WS] [WS-Client][handleHeader] - cProtocol:arduino
[WS] [WS-Client][handleHeader] - cExtensions:
[WS] [WS-Client][handleHeader] - cVersion:0
[WS] [WS-Client][handleHeader] - cSessionId:NsqUuXlPnVoCSumYAAAc
[WS] [WS-Client][handleHeader] Websocket connection init done.
[WS] [wsIOc] Connected to url:/socket.io/?EIO=4
[IOc] Connected to url: /socket.io/?EIO=4
[WS] [wsIOc] get pong
[IOc] Get PONG
[WS] [wsIOc] connected: len = 30
[WS] [wsIOc] data: {"sid":"cSx3YyFrDOfxUW8hAAAd"}
Message from Client :  { now: 30001 }

8.2 Server

Using the Socket.IO Server in Nodejs_SocketIO_TestServer

kh@kh-Inspiron-3593:~/Downloads/Nodejs/New_SIO$ nodejs app
Server launched on port 8080
Connected
cSx3YyFrDOfxUW8hAAAd
JWT token test:  { host: '192.168.2.30:8080',
  connection: 'keep-alive',
  authorization: '1234567890',
  'user-agent': 'arduino-WebSocket-Client' }
Message from Client :  { now: 30001 }

9. WebSocketClientSocketIO_W5500 on RASPBERRY_PI_PICO with W5x00 using Ethernet_Generic Library

The following are debug terminal output when running example WebSocketClientSocketIO_W5500 on RASPBERRY_PI_PICO with W5x00 and Ethernet_Generic Library using Earle Philhower's arduino-pico core v1.12.0

9.1 Client

Start WebSocketClientSocketIO_W5500 on RASPBERRY_PI_PICO with W5x00 using Ethernet_Generic Library
WebSockets_Generic v2.16.1
[WS] Board :RASPBERRY_PI_PICO, setCsPin:17
[WS] Default SPI pinout:
[WS] MOSI:19
[WS] MISO:16
[WS] SCK:18
[WS] SS:17
[WS] =========================
WebSockets Client @ IP address: 192.168.2.119
Connecting to WebSockets Server @ IP address: 192.168.2.30, port: 8080
[WS] WebSockets_Generic v2.16.1
[WS] [wsIOc] found EIO=4 disable EIO ping on client
[WS] [WS-Client][connectedCb] Connected to Host:192.168.2.30, Port:8080
[WS] [WS-Client] [sendHeader] Sending header...
[WS] sendHeader: client->cKey = rqJZ543MlA+uTo5YdFR+qA==
[WS] [WS-Client] [sendHeader] Handshake:GET /socket.io/?EIO=4&transport=polling HTTP/1.1
Host: 192.168.2.30:8080
Connection: keep-alive
Authorization: 1234567890
User-Agent: arduino-WebSocket-Client
[WS] [WS-Client] [sendHeader] Sending header... Done (us):2184
[WS] [WS-Client][handleHeader] RX:HTTP/1.1 200 OK
[WS] [WS-Client][handleHeader] RX:Content-Type: text/plain; charset=UTF-8
[WS] [WS-Client][handleHeader] RX:Content-Length: 97
[WS] [WS-Client][handleHeader] RX:Date: Mon, 24 May 2021 04:29:00 GMT
[WS] [WS-Client][handleHeader] RX:Connection: keep-alive
[WS] [WS-Client][handleHeader] Header read fin.
[WS] [WS-Client][handleHeader] Client settings:
[WS] [WS-Client][handleHeader] - cURL:/socket.io/?EIO=4
[WS] [WS-Client][handleHeader] - cKey:rqJZ543MlA+uTo5YdFR+qA==
[WS] [WS-Client][handleHeader] Server header:
[WS] [WS-Client][handleHeader] - cCode:200
[WS] [WS-Client][handleHeader] - cIsUpgrade:0
[WS] [WS-Client][handleHeader] - cIsWebsocket:1
[WS] [WS-Client][handleHeader] - cAccept:
[WS] [WS-Client][handleHeader] - cProtocol:arduino
[WS] [WS-Client][handleHeader] - cExtensions:
[WS] [WS-Client][handleHeader] - cVersion:0
[WS] [WS-Client][handleHeader] - cSessionId:
[WS] [WS-Client][handleHeader] Still missing cSessionId try Socket.IO
[WS] [WS-Client][handleHeader] socket.io json: 0{"sid":"TCiWG1KEq2MHPezpAAAg","upgrades":["websocket"],"pingInterval":25000,"pingTimeout":20000}
[WS] [WS-Client][handleHeader] - cSessionId: TCiWG1KEq2MHPezpAAAg
[WS] [WS-Client][handleHeader] Header read fin.
[WS] [WS-Client][handleHeader] Client settings:
[WS] [WS-Client][handleHeader] - cURL:/socket.io/?EIO=4
[WS] [WS-Client][handleHeader] - cKey:rqJZ543MlA+uTo5YdFR+qA==
[WS] [WS-Client][handleHeader] Server header:
[WS] [WS-Client][handleHeader] - cCode:200
[WS] [WS-Client][handleHeader] - cIsUpgrade:0
[WS] [WS-Client][handleHeader] - cIsWebsocket:1
[WS] [WS-Client][handleHeader] - cAccept:
[WS] [WS-Client][handleHeader] - cProtocol:arduino
[WS] [WS-Client][handleHeader] - cExtensions:
[WS] [WS-Client][handleHeader] - cVersion:0
[WS] [WS-Client][handleHeader] - cSessionId:TCiWG1KEq2MHPezpAAAg
[WS] [WS-Client][handleHeader] found cSessionId
[WS] [WS-Client] [sendHeader] Sending header...
[WS] sendHeader: client->cKey = ADdto91YKZwqbZ0X0v5ceg==
[WS] [WS-Client] [sendHeader] Handshake:GET /socket.io/?EIO=4&transport=websocket&sid=TCiWG1KEq2MHPezpAAAg HTTP/1.1
Host: 192.168.2.30:8080
Connection: Upgrade
Upgrade: websocket
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: ADdto91YKZwqbZ0X0v5ceg==
Sec-WebSocket-Protocol: arduino
Authorization: 1234567890
User-Agent: arduino-WebSocket-Client
[WS] [WS-Client] [sendHeader] Sending header... Done (us):2851
[WS] [WS-Client][handleHeader] RX:HTTP/1.1 101 Switching Protocols
[WS] [WS-Client][handleHeader] RX:Upgrade: websocket
[WS] [WS-Client][handleHeader] RX:Connection: Upgrade
[WS] [WS-Client][handleHeader] RX:Sec-WebSocket-Accept: gKekYE3itucoN6vDWPglIu3GU1U=
[WS] [WS-Client][handleHeader] RX:Sec-WebSocket-Protocol: arduino
[WS] [WS-Client][handleHeader] Header read fin.
[WS] [WS-Client][handleHeader] Client settings:
[WS] [WS-Client][handleHeader] - cURL:/socket.io/?EIO=4
[WS] [WS-Client][handleHeader] - cKey:ADdto91YKZwqbZ0X0v5ceg==
[WS] [WS-Client][handleHeader] Server header:
[WS] [WS-Client][handleHeader] - cCode:101
[WS] [WS-Client][handleHeader] - cIsUpgrade:1
[WS] [WS-Client][handleHeader] - cIsWebsocket:1
[WS] [WS-Client][handleHeader] - cAccept:gKekYE3itucoN6vDWPglIu3GU1U=
[WS] [WS-Client][handleHeader] - cProtocol:arduino
[WS] [WS-Client][handleHeader] - cExtensions:
[WS] [WS-Client][handleHeader] - cVersion:0
[WS] [WS-Client][handleHeader] - cSessionId:TCiWG1KEq2MHPezpAAAg
[WS] [WS-Client][handleHeader] Websocket connection init done.
[WS] [wsIOc] Connected to url:/socket.io/?EIO=4
[IOc] Connected to url: /socket.io/?EIO=4
[WS] [wsIOc] get pong
[IOc] Get PONG
[WS] [wsIOc] connected: len = 30
[WS] [wsIOc] data: {"sid":"kcgaqp1ovWXOgjCnAAAh"}
["event_name",{"now":30001}]
[WS] [wsIOc] get ping send pong:3
[IOc] Get PING
[WS] [WS-Client] Sending HB ping
["event_name",{"now":60002}]
[WS] [wsIOc] get ping send pong:3
[WS] [wsIOc] get ping send pong:3
["event_name",{"now":90003}]
[WS] [wsIOc] get ping send pong:3
[IOc] Get PING
[WS] [WS-Client] Sending HB ping
["event_name",{"now":120004}]
[WS] [wsIOc] get ping send pong:3
["event_name",{"now":150005}]
[WS] [wsIOc] get ping send pong:3

9.2 Server

Using the Socket.IO Server in Nodejs_SocketIO_TestServer

kh@kh-Inspiron-3593:~/Downloads/Nodejs/New_SIO$ nodejs app
Server launched on port 8080
Connected
kcgaqp1ovWXOgjCnAAAh
JWT token test:  { host: '192.168.2.30:8080',
  connection: 'keep-alive',
  authorization: '1234567890',
  'user-agent': 'arduino-WebSocket-Client' }
Message from Client :  { now: 30001 }
Message from Client :  { now: 60002 }
Message from Client :  { now: 90003 }
Message from Client :  { now: 120004 }
Message from Client :  { now: 150005 }

10. WebSocketClientSocketIO_W5500 on MBED RASPBERRY_PI_PICO with W5x00 using Ethernet_Generic Library

The following are debug terminal output when running example WebSocketClientSocketIO_W5500 on RASPBERRY_PI_PICO with W5x00 and Ethernet_Generic Library using Arduino-mbed RP2040 core

10.1 Client

Start WebSocketClientSocketIO_W5500 on RaspberryPi Pico with W5x00 using Ethernet_Generic Library
WebSockets_Generic v2.16.1
[WS] Board :RaspberryPi Pico, setCsPin:17
[WS] Default SPI pinout:
[WS] MOSI:19
[WS] MISO:16
[WS] SCK:18
[WS] SS:17
[WS] =========================
WebSockets Client @ IP address: 192.168.2.98
Connecting to WebSockets Server @ IP address: 192.168.2.30, port: 8080
[WS] WebSockets_Generic v2.16.1
[WS] [wsIOc] found EIO=4 disable EIO ping on client
[WS] [WS-Client][connectedCb] Connected to Host:192.168.2.30, Port:8080
[WS] [WS-Client] [sendHeader] Sending header...
[WS] sendHeader: client->cKey = fDyOMZVB7gvbnhOZclfWcA==
[WS] [WS-Client] [sendHeader] Handshake:GET /socket.io/?EIO=4&transport=polling HTTP/1.1
Host: 192.168.2.30:8080
Connection: keep-alive
Authorization: 1234567890
User-Agent: arduino-WebSocket-Client
[WS] [WS-Client] [sendHeader] Sending header... Done (us):3217
[WS] [WS-Client][handleHeader] RX:HTTP/1.1 200 OK
[WS] [WS-Client][handleHeader] RX:Content-Type: text/plain; charset=UTF-8
[WS] [WS-Client][handleHeader] RX:Content-Length: 97
[WS] [WS-Client][handleHeader] RX:Date: Mon, 24 May 2021 04:37:41 GMT
[WS] [WS-Client][handleHeader] RX:Connection: keep-alive
[WS] [WS-Client][handleHeader] Header read fin.
[WS] [WS-Client][handleHeader] Client settings:
[WS] [WS-Client][handleHeader] - cURL:/socket.io/?EIO=4
[WS] [WS-Client][handleHeader] - cKey:fDyOMZVB7gvbnhOZclfWcA==
[WS] [WS-Client][handleHeader] Server header:
[WS] [WS-Client][handleHeader] - cCode:200
[WS] [WS-Client][handleHeader] - cIsUpgrade:0
[WS] [WS-Client][handleHeader] - cIsWebsocket:1
[WS] [WS-Client][handleHeader] - cAccept:
[WS] [WS-Client][handleHeader] - cProtocol:arduino
[WS] [WS-Client][handleHeader] - cExtensions:
[WS] [WS-Client][handleHeader] - cVersion:0
[WS] [WS-Client][handleHeader] - cSessionId:
[WS] [WS-Client][handleHeader] Still missing cSessionId try Socket.IO
[WS] [WS-Client][handleHeader] socket.io json: 0{"sid":"7zb9ikut5ezr2H6kAAAi","upgrades":["websocket"],"pingInterval":25000,"pingTimeout":20000}
[WS] [WS-Client][handleHeader] - cSessionId: 7zb9ikut5ezr2H6kAAAi
[WS] [WS-Client][handleHeader] Header read fin.
[WS] [WS-Client][handleHeader] Client settings:
[WS] [WS-Client][handleHeader] - cURL:/socket.io/?EIO=4
[WS] [WS-Client][handleHeader] - cKey:fDyOMZVB7gvbnhOZclfWcA==
[WS] [WS-Client][handleHeader] Server header:
[WS] [WS-Client][handleHeader] - cCode:200
[WS] [WS-Client][handleHeader] - cIsUpgrade:0
[WS] [WS-Client][handleHeader] - cIsWebsocket:1
[WS] [WS-Client][handleHeader] - cAccept:
[WS] [WS-Client][handleHeader] - cProtocol:arduino
[WS] [WS-Client][handleHeader] - cExtensions:
[WS] [WS-Client][handleHeader] - cVersion:0
[WS] [WS-Client][handleHeader] - cSessionId:7zb9ikut5ezr2H6kAAAi
[WS] [WS-Client][handleHeader] found cSessionId
[WS] [WS-Client] [sendHeader] Sending header...
[WS] sendHeader: client->cKey = m1MElaS+NSouCUhWjSLPug==
[WS] [WS-Client] [sendHeader] Handshake:GET /socket.io/?EIO=4&transport=websocket&sid=7zb9ikut5ezr2H6kAAAi HTTP/1.1
Host: 192.168.2.30:8080
Connection: Upgrade
Upgrade: websocket
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: m1MElaS+NSouCUhWjSLPug==
Sec-WebSocket-Protocol: arduino
Authorization: 1234567890
User-Agent: arduino-WebSocket-Client
[WS] [WS-Client] [sendHeader] Sending header... Done (us):4878
[WS] [WS-Client][handleHeader] RX:HTTP/1.1 101 Switching Protocols
[WS] [WS-Client][handleHeader] RX:Upgrade: websocket
[WS] [WS-Client][handleHeader] RX:Connection: Upgrade
[WS] [WS-Client][handleHeader] RX:Sec-WebSocket-Accept: r/1zdz7Sk+4eMliZJTebh6cH7uw=
[WS] [WS-Client][handleHeader] RX:Sec-WebSocket-Protocol: arduino
[WS] [WS-Client][handleHeader] Header read fin.
[WS] [WS-Client][handleHeader] Client settings:
[WS] [WS-Client][handleHeader] - cURL:/socket.io/?EIO=4
[WS] [WS-Client][handleHeader] - cKey:m1MElaS+NSouCUhWjSLPug==
[WS] [WS-Client][handleHeader] Server header:
[WS] [WS-Client][handleHeader] - cCode:101
[WS] [WS-Client][handleHeader] - cIsUpgrade:1
[WS] [WS-Client][handleHeader] - cIsWebsocket:1
[WS] [WS-Client][handleHeader] - cAccept:r/1zdz7Sk+4eMliZJTebh6cH7uw=
[WS] [WS-Client][handleHeader] - cProtocol:arduino
[WS] [WS-Client][handleHeader] - cExtensions:
[WS] [WS-Client][handleHeader] - cVersion:0
[WS] [WS-Client][handleHeader] - cSessionId:7zb9ikut5ezr2H6kAAAi
[WS] [WS-Client][handleHeader] Websocket connection init done.
[WS] [wsIOc] Connected to url:/socket.io/?EIO=4
[IOc] Connected to url: /socket.io/?EIO=4
[WS] [wsIOc] get pong
[IOc] Get PONG
[WS] [wsIOc] connected: len = 30
[WS] [wsIOc] data: {"sid":"7SXGNMJxjtzOWXClAAAj"}
["event_name",{"now":30001}]
[WS] [wsIOc] get ping send pong:3
[IOc] Get PING
[WS] [WS-Client] Sending HB ping
["event_name",{"now":60002}]
[WS] [wsIOc] get ping send pong:3
["event_name",{"now":90003}]
[WS] [wsIOc] get ping send pong:3
[WS] [wsIOc] get ping send pong:3
[IOc] Get PING
[WS] [WS-Client] Sending HB ping
["event_name",{"now":120004}]

10.2 Server

Using the Socket.IO Server in Nodejs_SocketIO_TestServer

kh@kh-Inspiron-3593:~/Downloads/Nodejs/New_SIO$ nodejs app
Server launched on port 8080
Connected
7SXGNMJxjtzOWXClAAAj
JWT token test:  { host: '192.168.2.30:8080',
  connection: 'keep-alive',
  authorization: '1234567890',
  'user-agent': 'arduino-WebSocket-Client' }
Message from Client :  { now: 30001 }
Message from Client :  { now: 60002 }
Message from Client :  { now: 90003 }
Message from Client :  { now: 120005 }

The following are debug terminal output when running example WT32_ETH01_WebSocketClientSocketIO on WT32_ETH01

11.1 Client

Starting WT32_ETH01_WebSocketClient on ESP32_DEV with ETH_PHY_LAN8720
WebServer_WT32_ETH01 v1.4.1
WebSockets_Generic v2.16.1
ETH MAC: A8:03:2A:A1:61:73, IPv4: 192.168.2.232, FULL_DUPLEX, 100Mbps
WebSockets Client started @ IP address: 192.168.2.232
Connecting to WebSockets Server @ IP address: 192.168.2.30, port: 8080
[WS] [WS-Client] Connect ws...
[IOc] Disconnected
[WS] [WS-Client] Connect ws...
[WS] [WS-Client][connectedCb] Connected to Host:192.168.2.30, Port:8080
[WS] [wsIOc] Connected to url:/socket.io/?EIO=4
[IOc] Connected to url: /socket.io/?EIO=4
[WS] [wsIOc] get pong
[IOc] Get PONG
[WS] [wsIOc] connected: len = 30
[WS] [wsIOc] data: {"sid":"cxEI-kMvZ1uKiyQ-AAAB"}
["event_name",{"now":30001}]
[WS] [wsIOc] get event: len = 53
[WS] [wsIOc] get data: ["Send Message io.emit Broadcasted : ",{"now":30001}]
[IOc] Get event: ["Send Message io.emit Broadcasted : ",{"now":30001}]
[WS] [wsIOc] get event: len = 33
[WS] [wsIOc] get data: ["Send Message : ",{"now":30001}]
[IOc] Get event: ["Send Message : ",{"now":30001}]
[WS] [wsIOc] get ping send pong:3
[IOc] Get PING
[WS] [WS-Client] Sending HB ping
["event_name",{"now":60002}]
[WS] [wsIOc] get event: len = 53
[WS] [wsIOc] get data: ["Send Message io.emit Broadcasted : ",{"now":60002}]
[IOc] Get event: ["Send Message io.emit Broadcasted : ",{"now":60002}]
[WS] [wsIOc] get event: len = 33
[WS] [wsIOc] get data: ["Send Message : ",{"now":60002}]
[IOc] Get event: ["Send Message : ",{"now":60002}]
[WS] [wsIOc] get ping send pong:3
["event_name",{"now":90003}]
[WS] [wsIOc] get event: len = 53
[WS] [wsIOc] get data: ["Send Message io.emit Broadcasted : ",{"now":90003}]
[IOc] Get event: ["Send Message io.emit Broadcasted : ",{"now":90003}]
[WS] [wsIOc] get event: len = 33
[WS] [wsIOc] get data: ["Send Message : ",{"now":90003}]
[IOc] Get event: ["Send Message : ",{"now":90003}]
[WS] [wsIOc] get ping send pong:3
[IOc] Get PING
[WS] [WS-Client] Sending HB ping
["event_name",{"now":120004}]
[WS] [wsIOc] get event: len = 54
[WS] [wsIOc] get data: ["Send Message io.emit Broadcasted : ",{"now":120004}]
[IOc] Get event: ["Send Message io.emit Broadcasted : ",{"now":120004}]
[WS] [wsIOc] get event: len = 34
[WS] [wsIOc] get data: ["Send Message : ",{"now":120004}]
[IOc] Get event: ["Send Message : ",{"now":120004}]
[WS] [wsIOc] get ping send pong:3

11.2 Server

Using the Socket.IO Server in Nodejs_SocketIO_TestServer

kh@kh-Inspiron-3593:~/Downloads/Nodejs/New_SIO$ nodejs app
Server launched on port 8080
Connected
cxEI-kMvZ1uKiyQ-AAAB
JWT token test:  { host: '192.168.2.30:8080',
  connection: 'keep-alive',
  authorization: '1234567890',
  'user-agent': 'arduino-WebSocket-Client' }
Message from Client :  { now: 30001 }
Message from Client :  { now: 60002 }
Message from Client :  { now: 90003 }
Message from Client :  { now: 120004 }

12. Teensy_WebSocketClientSocketIO_QNEthernet on TEENSY 4.1 using QNEthernet

The following are debug terminal output when running example Teensy_WebSocketClientSocketIO_QNEthernet on TEENSY 4.1 using QNEthernet library

12.1 Client

Starting Teensy_WebSocketClient_QNEthernet on TEENSY 4.1 using QNEthernet
WebSockets_Generic v2.16.1
=========== USE_QN_ETHERNET ===========
Initialize Ethernet using static IP => Connected! IP address:192.168.2.222
Connecting to WebSockets Server @ IP address: 192.168.2.30, port: 8080
[IOc] Connected to url: /socket.io/?EIO=4
["event_name",{"now":30001}]
[IOc] Get event: ["Send Message io.emit Broadcasted : ",{"now":30001}]
[IOc] Get event: ["Send Message : ",{"now":30001}]
["event_name",{"now":60002}]
[IOc] Get event: ["Send Message io.emit Broadcasted : ",{"now":60002}]
[IOc] Get event: ["Send Message : ",{"now":60002}]
["event_name",{"now":90003}]
[IOc] Get event: ["Send Message io.emit Broadcasted : ",{"now":90003}]
[IOc] Get event: ["Send Message : ",{"now":90003}]

12.2 Server

Using the Socket.IO Server in Nodejs_SocketIO_TestServer

kh@kh-Inspiron-3593:~/Downloads/Nodejs/New_SIO$ ./SIO_server.sh 
Server launched on port 8080
Connected
bK733pVgbd3DCsy5AAAB
JWT token test:  { host: '192.168.2.30:8080',
  connection: 'keep-alive',
  authorization: '1234567890',
  'user-agent': 'arduino-WebSocket-Client' }
Message from Client :  { now: 30001 }
Message from Client :  { now: 60002 }
Message from Client :  { now: 90003 }

13. Portenta_H7_WebSocketClientSocketIO on PORTENTA_H7_M7 with Ethernet

The following are debug terminal output when running example Portenta_H7_WebSocketClientSocketIO on PORTENTA_H7_M7 with Ethernet using Portenta_Ethernet Library

13.1 Client

Start Portenta_H7_WebSocketClientSocketIO on PORTENTA_H7_M7 with Ethernet using Portenta_Ethernet Library
WebSockets_Generic v2.16.1
WebSockets Client @ IP address: 192.168.2.132
Connecting to WebSockets Server @ IP address: 192.168.2.30, port: 8080
[WS] [WS-Client][connectedCb] Connected to Host:192.168.2.30, Port:8080
[WS] [wsIOc] Connected to url:/socket.io/?EIO=4
[IOc] Connected to url: /socket.io/?EIO=4
[WS] [wsIOc] get pong
[IOc] Get PONG
[WS] [wsIOc] connected: len = 30
[WS] [wsIOc] data: {"sid":"RqchvIdY1DWbvxTpAAAB"}
["event_name",{"now":30001}]
[WS] [wsIOc] get event: len = 53
[WS] [wsIOc] get data: ["Send Message io.emit Broadcasted : ",{"now":30001}]
[IOc] Get event: ["Send Message io.emit Broadcasted : ",{"now":30001}]
[WS] [wsIOc] get event: len = 33
[WS] [wsIOc] get data: ["Send Message : ",{"now":30001}]
[IOc] Get event: ["Send Message : ",{"now":30001}]
[WS] [wsIOc] get ping send pong:3
[IOc] Get PING
[WS] [WS-Client] Sending HB ping
["event_name",{"now":60006}]
[WS] [wsIOc] get event: len = 53
[WS] [wsIOc] get data: ["Send Message io.emit Broadcasted : ",{"now":60006}]
[IOc] Get event: ["Send Message io.emit Broadcasted : ",{"now":60006}]
[WS] [wsIOc] get event: len = 33
[WS] [wsIOc] get data: ["Send Message : ",{"now":60006}]
[IOc] Get event: ["Send Message : ",{"now":60006}]
[WS] [wsIOc] get ping send pong:3

13.2 Server

Using the Socket.IO Server in Nodejs_SocketIO_TestServer

kh@kh-Inspiron-3593:~/Downloads/Nodejs/New_SIO$ ./SIO_server.sh 
Server launched on port 8080
Connected
RqchvIdY1DWbvxTpAAAB
JWT token test:  { host: '192.168.2.30:8080',
  connection: 'keep-alive',
  authorization: '1234567890',
  'user-agent': 'arduino-WebSocket-Client' }
Message from Client :  { now: 30001 }
Message from Client :  { now: 60006 }

14. WebSocketClientSocketIO_WiFi on Portenta_H7 using WiFi

The following are debug terminal output when running example WebSocketClientSocketIO_WiFi on Portenta_H7 using Murata WiFi

14.1 Client

Start WebSocketClientSocketIO_WiFi on PORTENTA_H7_M7
WebSockets_Generic v2.16.1
Connecting to SSID: HueNet1
SSID: HueNet1
WebSockets Client IP Address: 192.168.2.130
signal strength (RSSI):-27 dBm
Connecting to WebSockets Server @ IP address: 192.168.2.30, port: 8080
[IOc] Connected to url: /socket.io/?EIO=4
["event_name",{"now":30001}]
[IOc] Get event: ["Send Message io.emit Broadcasted : ",{"now":30001}]
[IOc] Get event: ["Send Message : ",{"now":30001}]
["event_name",{"now":60002}]
[IOc] Get event: ["Send Message io.emit Broadcasted : ",{"now":60002}]
[IOc] Get event: ["Send Message : ",{"now":60002}]
["event_name",{"now":90003}]
[IOc] Get event: ["Send Message io.emit Broadcasted : ",{"now":90003}]
[IOc] Get event: ["Send Message : ",{"now":90003}]
["event_name",{"now":121501}]
[IOc] Get event: ["Send Message io.emit Broadcasted : ",{"now":121501}]
[IOc] Get event: ["Send Message : ",{"now":121501}]
["event_name",{"now":151503}]
[IOc] Get event: ["Send Message io.emit Broadcasted : ",{"now":151503}]
[IOc] Get event: ["Send Message : ",{"now":151503}]

14.2 Server

Using the Socket.IO Server in Nodejs_SocketIO_TestServer

kh@kh-Inspiron-3593:~/Downloads/Nodejs/New_SIO$ ./SIO_server.sh 
Server launched on port 8080
Connected
nr4syN7HdG1PlCYrAAAF
JWT token test:  { host: '192.168.2.30:8080',
  connection: 'keep-alive',
  authorization: '1234567890',
  'user-agent': 'arduino-WebSocket-Client' }
Message from Client :  { now: 30001 }
Message from Client :  { now: 60002 }
Message from Client :  { now: 90003 }
Message from Client :  { now: 121501 }
Message from Client :  { now: 151503 }
Message from Client :  { now: 181506 }

15. Portenta_H7_WebSocketClient_Sticky_SocketIO on PORTENTA_H7_M7 using Ethernet

The following are debug terminal output when running example Portenta_H7_WebSocketClient_Sticky_SocketIO on Portenta_H7 using Vision-shield Ethernet.

Start Portenta_H7_WebSocketClient_Sticky_SocketIO on PORTENTA_H7_M7 with Ethernet using Portenta_Ethernet Library
WebSockets_Generic v2.16.1
WebSockets Client @ IP address: 192.168.2.133
Connecting to WebSockets Server @ IP address: 192.168.2.30, port: 8080
[WS] WebSockets_Generic v2.16.1
[WS] [wsIOc] found EIO=4 disable EIO ping on client
[WS] [WS-Client][connectedCb] Connected to Host:192.168.2.30, Port:8080
[WS] [WS-Client] [sendHeader] Sending header...
[WS] sendHeader: client->cKey = Kp/b0RFGMw/WSNGn35/s3A==
[WS] [WS-Client] [sendHeader] Handshake:GET /socket.io/?EIO=4&transport=websocket HTTP/1.1
Host: 192.168.2.30:8080
Connection: keep-alive
Authorization: 1234567890
User-Agent: arduino-WebSocket-Client
[WS] [WS-Client] [sendHeader] Sending header... Done (us):712
[WS] [WS-Client][handleHeader] RX:HTTP/1.1 200 OK
[WS] [WS-Client][handleHeader] RX:Date: Sun, 12 Dec 2021 05:58:29 GMT
[WS] [WS-Client][handleHeader] RX:Connection: keep-alive
[WS] [WS-Client][handleHeader] RX:Keep-Alive: timeout=5
[WS] [WS-Client][handleHeader] RX:Transfer-Encoding: chunked
[WS] [WS-Client][handleHeader] Header read fin.
[WS] [WS-Client][handleHeader] Client settings:
[WS] [WS-Client][handleHeader] - cURL:/socket.io/?EIO=4
[WS] [WS-Client][handleHeader] - cKey:Kp/b0RFGMw/WSNGn35/s3A==
[WS] [WS-Client][handleHeader] Server header:
[WS] [WS-Client][handleHeader] - cCode:200
[WS] [WS-Client][handleHeader] - cIsUpgrade:0
[WS] [WS-Client][handleHeader] - cIsWebsocket:1
[WS] [WS-Client][handleHeader] - cAccept:
[WS] [WS-Client][handleHeader] - cProtocol:arduino
[WS] [WS-Client][handleHeader] - cExtensions:
[WS] [WS-Client][handleHeader] - cVersion:0
[WS] [WS-Client][handleHeader] - cSessionId:
[WS] [WS-Client][handleHeader] Still missing cSessionId try Socket.IO
[WS] [WS-Client][handleHeader] socket.io json: c
hello world
0
[WS] [WS-Client][handleHeader] RX:c
hello world
0
[WS] [WS-Client][handleHeader] Header error:c
hello world
0
[WS] [WS-Client][handleClientData] Header response timeout.. Disconnecting!
[IOc] Disconnected
[WS] [wsIOc] Disconnected!
[WS] [WS-Client][connectedCb] Connected to Host:192.168.2.30, Port:8080
[WS] [WS-Client] [sendHeader] Sending header...
[WS] sendHeader: client->cKey = dm6SsOCMRZwhNjKmQeo2lw==
[WS] [WS-Client] [sendHeader] Handshake:GET /socket.io/?EIO=4&transport=websocket HTTP/1.1
Host: 192.168.2.30:8080
Connection: keep-alive
Authorization: 1234567890
User-Agent: arduino-WebSocket-Client

The following are debug terminal output when running example ESP32_WebSocketClientSocketIO on ESP32S3_DEV

Start ESP32_WebSocketClientSocketIO on ESP32S3_DEV
WebSockets_Generic v2.16.1
Connecting to HueNet1
WebSockets Client started @ IP address: 192.168.2.83
Connecting to WebSockets Server @ IP address: 192.168.2.30, port: 8080
[WS] [WS-Client] beginSocketIO with IPAddress
[WS] [WS-Client] beginSocketIO with const char
[WS] WebSockets_Generic v2.12.0
[WS] [wsIOc] found EIO=4 disable EIO ping on client
[WS] [WS-Client] Connect ws...
[WS] [WS-Client] Calling _client.tcp->connect, _host =192.168.2.30, port =8080
[WS] [WS-Client] Calling _client.tcp->connect, _connectResult =1
[WS] [WS-Client] connectedCb
[WS] [WS-Client][connectedCb] Connected to Host:192.168.2.30, Port:8080
[WS] [WS-Client] [sendHeader] Sending header...
[WS] sendHeader: client->cKey = 8FGfIMaycpbZsGx1WcjYPg==
[WS] [WS-Client] [sendHeader] Handshake:GET /socket.io/?EIO=4&transport=polling HTTP/1.1
Host: 192.168.2.30:8080
Connection: keep-alive
Authorization: 1234567890
User-Agent: arduino-WebSocket-Client
[WS] [write] n:166, t:10047
[WS] [write] Write, Length :166, Left :0
[WS] [WS-Client] [sendHeader] Sending header... Done (us):32263
[WS] [WS-Client][handleHeader] RX:HTTP/1.1 200 OK
[WS] [WS-Client][handleHeader] RX:Content-Type: text/plain; charset=UTF-8
[WS] [WS-Client][handleHeader] RX:Content-Length: 97
[WS] [WS-Client][handleHeader] RX:Date: Mon, 14 Feb 2022 23:52:21 GMT
[WS] [WS-Client][handleHeader] RX:Connection: keep-alive
[WS] [WS-Client][handleHeader] RX:Keep-Alive: timeout=5
[WS] [WS-Client][handleHeader] Header read fin.
[WS] [WS-Client][handleHeader] Client settings:
[WS] [WS-Client][handleHeader] - cURL:/socket.io/?EIO=4
[WS] [WS-Client][handleHeader] - cKey:8FGfIMaycpbZsGx1WcjYPg==
[WS] [WS-Client][handleHeader] Server header:
[WS] [WS-Client][handleHeader] - cCode:200
[WS] [WS-Client][handleHeader] - cIsUpgrade:0
[WS] [WS-Client][handleHeader] - cIsWebsocket:1
[WS] [WS-Client][handleHeader] - cAccept:
[WS] [WS-Client][handleHeader] - cProtocol:arduino
[WS] [WS-Client][handleHeader] - cExtensions:
[WS] [WS-Client][handleHeader] - cVersion:0
[WS] [WS-Client][handleHeader] - cSessionId:
[WS] [WS-Client][handleHeader] Still missing cSessionId try Socket.IO
[WS] [WS-Client][handleHeader] socket.io json: 0{"sid":"p6g2ESTze400qtXcAAAE","upgrades":["websocket"],"pingInterval":25000,"pingTimeout":20000}
[WS] [WS-Client][handleHeader] - cSessionId: p6g2ESTze400qtXcAAAE
[WS] [WS-Client][handleHeader] Header read fin.
[WS] [WS-Client][handleHeader] Client settings:
[WS] [WS-Client][handleHeader] - cURL:/socket.io/?EIO=4
[WS] [WS-Client][handleHeader] - cKey:8FGfIMaycpbZsGx1WcjYPg==
[WS] [WS-Client][handleHeader] Server header:
[WS] [WS-Client][handleHeader] - cCode:200
[WS] [WS-Client][handleHeader] - cIsUpgrade:0
[WS] [WS-Client][handleHeader] - cIsWebsocket:1
[WS] [WS-Client][handleHeader] - cAccept:
[WS] [WS-Client][handleHeader] - cProtocol:arduino
[WS] [WS-Client][handleHeader] - cExtensions:
[WS] [WS-Client][handleHeader] - cVersion:0
[WS] [WS-Client][handleHeader] - cSessionId:p6g2ESTze400qtXcAAAE
[WS] [WS-Client][handleHeader] found cSessionId
[WS] [WS-Client] [sendHeader] Sending header...
[WS] sendHeader: client->cKey = 2btvEqbCEn69Vmh40QfIaA==
[WS] [WS-Client] [sendHeader] Handshake:GET /socket.io/?EIO=4&transport=websocket&sid=p6g2ESTze400qtXcAAAE HTTP/1.1
Host: 192.168.2.30:8080
Connection: Upgrade
Upgrade: websocket
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: 2btvEqbCEn69Vmh40QfIaA==
Sec-WebSocket-Protocol: arduino
Authorization: 1234567890
User-Agent: arduino-WebSocket-Client
[WS] [write] n:315, t:10268
[WS] [write] Write, Length :315, Left :0
[WS] [WS-Client] [sendHeader] Sending header... Done (us):42597
[WS] [WS-Client][handleHeader] RX:HTTP/1.1 101 Switching Protocols
[WS] [WS-Client][handleHeader] RX:Upgrade: websocket
[WS] [WS-Client][handleHeader] RX:Connection: Upgrade
[WS] [WS-Client][handleHeader] RX:Sec-WebSocket-Accept: MokU7OGA/lZbCC0KeEZT6+rp5l0=
[WS] [WS-Client][handleHeader] RX:Sec-WebSocket-Protocol: arduino
[WS] [WS-Client][handleHeader] Header read fin.
[WS] [WS-Client][handleHeader] Client settings:
[WS] [WS-Client][handleHeader] - cURL:/socket.io/?EIO=4
[WS] [WS-Client][handleHeader] - cKey:2btvEqbCEn69Vmh40QfIaA==
[WS] [WS-Client][handleHeader] Server header:
[WS] [WS-Client][handleHeader] - cCode:101
[WS] [WS-Client][handleHeader] - cIsUpgrade:1
[WS] [WS-Client][handleHeader] - cIsWebsocket:1
[WS] [WS-Client][handleHeader] - cAccept:MokU7OGA/lZbCC0KeEZT6+rp5l0=
[WS] [WS-Client][handleHeader] - cProtocol:arduino
[WS] [WS-Client][handleHeader] - cExtensions:
[WS] [WS-Client][handleHeader] - cVersion:0
[WS] [WS-Client][handleHeader] - cSessionId:p6g2ESTze400qtXcAAAE
[WS] [WS-Client][handleHeader] Websocket connection init done.
[WS] [headerDone] Header Handling Done. Client:0
[WS] [wsIOc] Connected to url:/socket.io/?EIO=4
[WS] [sendFrame] ------- send message frame -------
[WS] [sendFrame] Client:0
[WS] fin:1
[WS] opCode:1
[WS] mask:1
[WS] length:6
[WS] headerToPayload:0
[WS] [sendFrame] Client: 0, text:2probe
[WS] [sendFrame] pack to one TCP package... Client:0
[WS] [write] n:12, t:10411
[WS] [write] Write, Length :12, Left :0
[WS] [sendFrame] ------- send message frame -------
[WS] [sendFrame] Client:0
[WS] fin:1
[WS] opCode:1
[WS] mask:1
[WS] length:1
[WS] headerToPayload:1
[WS] [sendFrame] Client: 0, text:5
[WS] [write] n:7, t:10433
[WS] [write] Write, Length :7, Left :0
[IOc] Connected to url: /socket.io/?EIO=4
[WS] [write] n:6, t:10435
[WS] [write] Write, Length :6, Left :0
[WS] [write] n:2, t:10446
[WS] [write] Write, Length :2, Left :0
[WS] [write] n:1, t:10447
[WS] [write] Write, Length :1, Left :0
[WS] [handleWebsocketWaitFor] Client: 0, size:2
[WS] cWsRXsize:0
[WS] [readCb] n:2, t:10459
[WS] [readCb] Receive Length =2, left =0
[WS] [handleWebsocketWaitFor][readCb] Client: 0, size:2
[WS] ok:1
[WS] [handleWebsocket] ------- read massage frame ------- Client:0
[WS] [handleWebsocket] Client: 0, fin:1
[WS] rsv1:0
[WS] rsv2:0
[WS] rsv3:0
[WS] opCode:1
[WS] [handleWebsocket] Client: 0, mask:0
[WS] payloadLen:6
[WS] [readCb] n:6, t:10491
[WS] [readCb] Receive Length =6, left =0
[WS] [handleWebsocketPayloadCb] Client: 0, text:3probe
[WS] [wsIOc] get pong
[IOc] Get PONG
[WS] [handleWebsocketWaitFor] Client: 0, size:2
[WS] cWsRXsize:0
[WS] [readCb] n:2, t:10512
[WS] [readCb] Receive Length =2, left =0
[WS] [handleWebsocketWaitFor][readCb] Client: 0, size:2
[WS] ok:1
[WS] [handleWebsocket] ------- read massage frame ------- Client:0
[WS] [handleWebsocket] Client: 0, fin:1
[WS] rsv1:0
[WS] rsv2:0
[WS] rsv3:0
[WS] opCode:1
[WS] [handleWebsocket] Client: 0, mask:0
[WS] payloadLen:32
[WS] [readCb] n:32, t:10544
[WS] [readCb] Receive Length =32, left =0
[WS] [handleWebsocketPayloadCb] Client: 0, text:40{"sid":"356v34mdH9BycjJpAAAF"}
[WS] [wsIOc] connected: len = 30
[WS] [wsIOc] data: {"sid":"356v34mdH9BycjJpAAAF"}

17. ESP8266_AsyncWSClient on ESP8266_NODEMCU_ESP12E

The following are debug terminal output when running example ESP8266_AsyncWSClient on ESP8266_NODEMCU_ESP12E

Start ESP8266_AsyncWSClient on ESP8266_NODEMCU_ESP12E
WebSockets_Generic v2.16.1
WebSockets Client started @ IP address: 192.168.2.145
Connecting to WebSockets Server @ 192.168.2.30
Connected to WebSockets Server @ IP address: 192.168.2.30
["From Async ESP8266_NODEMCU_ESP12E",{"now":2070}]
[WS] [WS-Client][connectedCb] Connected to Host:192.168.2.30, Port:8080
[WSc] Connected to url: /
[WSc] get text: Connected
[WSc] get ping
["From Async ESP8266_NODEMCU_ESP12E",{"now":32075}]
[WSc] get text: ["From Async Async ESP8266_NODEMCU_ESP12E",{"now":32075}]
[WSc] get ping
["From Async Async ESP8266_NODEMCU_ESP12E",{"now":62077}]
[WSc] get text: ["From Async ESP8266_NODEMCU_ESP12E",{"now":62077}]
[WSc] get ping
["From Async ESP8266_NODEMCU_ESP12E",{"now":92079}]
[WSc] get text: ["From Async ESP8266_NODEMCU_ESP12E",{"now":92079}]
[WSc] get ping
["From Async ESP8266_NODEMCU_ESP12E",{"now":122081}]
[WSc] get text: ["From Async ESP8266_NODEMCU_ESP12E",{"now":122081}]
[WSc] get ping
["From Async ESP8266_NODEMCU_ESP12E",{"now":152083}]
[WSc] get text: ["From Async ESP8266_NODEMCU_ESP12E",{"now":152083}]
[WSc] get ping
["From Async ESP8266_NODEMCU_ESP12E",{"now":182085}]
[WSc] get text: ["From Async ESP8266_NODEMCU_ESP12E",{"now":182085}]
[WSc] get ping
["From Async ESP8266_NODEMCU_ESP12E",{"now":212087}]
[WSc] get text: ["From Async ESP8266_NODEMCU_ESP12E",{"now":212087}]
[WSc] get ping
["From Async ESP8266_NODEMCU_ESP12E",{"now":242089}]
[WSc] get text: ["From Async ESP8266_NODEMCU_ESP12E",{"now":242089}]

18. WebSocketClientSocketIO_RP2040W on RP2040W using WiFi

The following are debug terminal output when running example WebSocketClientSocketIO_RP2040W on RP2040W using CYW43439 WiFi

18.1 Client

Start WebSocketClientSocketIO_RP2040W on RASPBERRY_PI_PICO_W
WebSockets_Generic v2.16.1
Connecting to SSID: HueNet1
SSID: HueNet1
WebSockets Client IP Address: 192.168.2.77
signal strength (RSSI):0 dBm
Connecting to WebSockets Server @ IP address: 192.168.2.30, port: 8080
[WS] [WS-Client] Connect ws...
[WS] [WS-Client][connectedCb] Connected to Host:192.168.2.30, Port:8080
[WS] [wsIOc] Connected to url:/socket.io/?EIO=4
[IOc] Connected to url: /socket.io/?EIO=4
[WS] [wsIOc] get pong
[IOc] Get PONG
[WS] [wsIOc] connected: len = 30
[WS] [wsIOc] data: {"sid":"M2cFjvQhLKXc6aB4AAAB"}
["event_name",{"now":30001}]
[WS] [wsIOc] get event: len = 53
[WS] [wsIOc] get data: ["Send Message io.emit Broadcasted : ",{"now":30001}]
[IOc] Get event: ["Send Message io.emit Broadcasted : ",{"now":30001}]
[WS] [wsIOc] get event: len = 33
[WS] [wsIOc] get data: ["Send Message : ",{"now":30001}]
[IOc] Get event: ["Send Message : ",{"now":30001}]
[WS] [wsIOc] get ping send pong:3
[IOc] Get PING
[WS] [WS-Client] Sending HB ping
["event_name",{"now":60002}]
[WS] [wsIOc] get event: len = 53
[WS] [wsIOc] get data: ["Send Message io.emit Broadcasted : ",{"now":60002}]
[IOc] Get event: ["Send Message io.emit Broadcasted : ",{"now":60002}]
[WS] [wsIOc] get event: len = 33
[WS] [wsIOc] get data: ["Send Message : ",{"now":60002}]
[IOc] Get event: ["Send Message : ",{"now":60002}]
[WS] [wsIOc] get ping send pong:3
[IOc] Get PING

18.2 Server

Using the Socket.IO Server in Nodejs_SocketIO_TestServer

kh@kh-Inspiron-3593:~/Downloads/Nodejs/New_SIO$ ./SIO_server.sh 
Server launched on port 8080
Connected
M2cFjvQhLKXc6aB4AAAB
JWT token test:  {
  host: '192.168.2.30:8080',
  connection: 'keep-alive',
  authorization: '1234567890',
  'user-agent': 'arduino-WebSocket-Client'
}
Message from Client :  { now: 30001 }
Message from Client :  { now: 60002 }

19. Generic_WebSocketClientSocketIO_WiFiNINA on Nano_RP2040_Connect using WiFiNINA

The following are debug terminal output when running example Generic_WebSocketClientSocketIO_WiFiNINA on Nano_RP2040_Connect using WiFiNINA

Start Generic_WebSocketClientSocketIO_WiFiNINA on Nano RP2040 Connect
WebSockets_Generic v2.16.1
Please upgrade the firmware
Attempting to connect to SSID: HueNet1
SSID: HueNet1
WebSockets Client IP Address: 192.168.2.105
signal strength (RSSI):-31 dBm
Connecting to WebSockets Server @ IP address: 192.168.2.30, port: 8080
[WS] [WS-Client] Connect ws...
[WS] [WS-Client][connectedCb] Connected to Host:192.168.2.30, Port:8080
[WS] [wsIOc] Connected to url:/socket.io/?EIO=4
[IOc] Connected to url: /socket.io/?EIO=4
[WS] [wsIOc] get pong
[IOc] Get PONG
[WS] [wsIOc] connected: len = 30
[WS] [wsIOc] data: {"sid":"m0VRTQ6jk6LggxnTAAAF"}
["event_name",{"now":30001}]
[WS] [wsIOc] get event: len = 57
[WS] [wsIOc] get data: ["Send Message socket.broadcast.emit : ",{"now":1950065}]
[IOc] Get event: ["Send Message socket.broadcast.emit : ",{"now":1950065}]
[WS] [wsIOc] get event: len = 55
[WS] [wsIOc] get data: ["Send Message io.emit Broadcasted : ",{"now":1950065}]
[IOc] Get event: ["Send Message io.emit Broadcasted : ",{"now":1950065}]
[WS] [wsIOc] get event: len = 53
[WS] [wsIOc] get data: ["Send Message io.emit Broadcasted : ",{"now":30001}]
[IOc] Get event: ["Send Message io.emit Broadcasted : ",{"now":30001}]
[WS] [wsIOc] get event: len = 33
[WS] [wsIOc] get data: ["Send Message : ",{"now":30001}]
[IOc] Get event: ["Send Message : ",{"now":30001}]
[WS] [wsIOc] get ping send pong:3
[IOc] Get PING


Debug

Debug is enabled by default on Serial. To disable, add at the beginning of sketch

/* Comment this out to disable prints and save space */
#define DEBUG_WEBSOCKETS_PORT         Serial

#define _WEBSOCKETS_LOGLEVEL_         4

Troubleshooting

If you get compilation errors, more often than not, you may need to install a newer version of the board's core, dependent libraries or this library version.

Sometimes, the library will only work if you update the core to the newer or older version because some function compatibility.



Issues

Submit issues to: WebSockets_Generic issues



TO DO

  1. Bug Searching and Killing
  2. Support more types of boards using WiFi/Ethernet shields (Teensy, etc.)
  3. Support more non-compatible Ethernet Libraries such as Ethernet_Shield_W5200, EtherCard, EtherSia
  4. Support ASYNC mode for boards using communication libraries supporting Async (STM32, Portenta, Teensy 4.1, ESP32, etc.)

DONE

  1. Add support to Arduino SAMD21 (ZERO, MKR, NANO_33_IOT, etc.)
  2. Add support to Adafruit SAMD21 (Itsy-Bitsy M0, Metro M0, Feather M0 Express, etc.).
  3. Add support to Adafruit SAMD51 (Itsy-Bitsy M4, Metro M4, Grand Central M4, Feather M4 Express, etc.).
  4. Add support to Adafruit nRF52 ( Feather nRF52832, nRF52840 Express, BlueFruit Sense, Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B302_ublox, NINA_B112_ublox, etc.
  5. Add support to Seeeduino SAMD21/SAMD51 boards (SEEED_WIO_TERMINAL, SEEED_FEMTO_M0, SEEED_XIAO_M0, Wio_Lite_MG126, WIO_GPS_BOARD, SEEEDUINO_ZERO, SEEEDUINO_LORAWAN, SEEED_GROVE_UI_WIRELESS, etc.)
  6. Add support to STM32F/L/H/G/WB/MP1 (Nucleo-144, Nucleo-64, Nucleo-32, Discovery, STM32Fx, STM32H7, STM32Lx, STM32Gx, STM32WB, STM32MP1, etc.) having 64K+ Flash program memory.
  7. Add support to Ethernet W5x00, using either Ethernet, Ethernet2, Ethernet3 or EthernetLarge library
  8. Add support to WiFiNINA using WiFiNINA or WiFiNINA_Generic library.
  9. Add support to ENC28J60 using UIPEthernet
  10. Add support to ENC28J60 using EthernetENC
  11. Add support to Teensy using W5x00, ENC28J60, WiFiNINA
  12. Add support to Teensy 4.1 built-in Ethernet using NativeEthernet library
  13. Add support to STM32F/L/H/G/WB/MP1 using built-in LAN8742A and STM32Ethernet
  14. Add support to SeeedStudio WIO Terminal with Realtek RTL8720DN WiFi using Seeed_Arduino_rpcWiFi and Seeed_Arduino_rpcUnified libraries
  15. Add support to SAMD_MKR1000 and SAMD_MKRWIFI1010 using WiFi101
  16. Fix breaking problem with SocketIO.
  17. Default to EIOv4
  18. Add support to RP2040-based boards, such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, using Earle Philhower's arduino-pico core v1.3.1+.
  19. Add support to RP2040-based boards, such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, using Arduino-mbed RP2040 core.
  20. Add support to WT32_ETH01 boards using ESP32-based boards and LAN8720 Ethernet
  21. Add support to Teensy 4.1 built-in Ethernet using QNEthernet library
  22. Add support to Portenta_H7, using either Murata WiFi or Vision-shield Ethernet
  23. Auto detect ESP32 core to use for WT32_ETH01
  24. Fix bug in WT32_ETH01 examples to reduce connection time
  25. Add option to use transport=websocket with sticky-session SIO server
  26. Add SSL support to ESP32-based WT32_ETH01 boards
  27. Add support to ESP32_S3, ESP32_C3
  28. Add sIOtype_PING and sIOtype_PING SocketIO events.
  29. Don't use deprecated sha.h for ESP32 core v1.0.6+.
  30. Optimize code by passing by reference instead of value
  31. Fix ASYNC bug for ESP8266 when using NETWORK_ESP8266_ASYNC
  32. Use new Ethernet_Generic library as default for W5x00.
  33. Add support to RP2040-based boards, such as Nano_RP2040_Connect, RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040, using WiFiNINA or Ethernet
  34. Add WS and BearSSL WSS support to RP2040W using CYW43439 WiFi with arduino-pico core
  35. Optional user-defined
  • WEBSOCKETS_TCP_TIMEOUT, default 5,000ms
  • EIO_HEARTBEAT_INTERVAL, default 20,000ms
  • SIO_PING_INTERVAL, default 60,000ms
  • SIO_PONG_TIMEOUT, default 90,000ms
  • SIO_DISCONNECT_TIMEOUT_COUNT, default 5
  1. Add astyle using allman style. Restyle the library


Contributions and Thanks

  1. Based on and modified from Markus Sattler's arduinoWebSockets library
  2. Thanks to Anson He for the PR Fix compile error for Wio Terminal to fix SeeedStudio SEEED_WIO_TERMINAL compile errors and leading to new version v2.3.3.
  3. Thanks to Jose A.Molina for the enhancement request WiFi101 and Arduino MKR1000. #10, and help testing, leading to new version v2.5.0, and v2.6.0
  4. Thanks to Ideen Kaffee Korner for
Links2004
⭐️⭐️ Markus Sattler

ansonhe97
Anson He

Josua2012
Jose A. Molina

iKK001
⭐️ Ideen Kaffee Korner


Contributing

If you want to contribute to this project:

  • Report bugs and errors
  • Ask for enhancements
  • Create issues and pull requests
  • Tell other people about this library


License and credits

  • Most of the credits go to original author Markus Sattler.

  • The library is licensed under GPLv3

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


Copyright

  1. Copyright (c) 2016- Markus Sattler
  2. Copyright (c) 2020- Khoi Hoang

websockets_generic's People

Contributors

ansonhex avatar dependabot[bot] avatar khoih-prog avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

websockets_generic's Issues

Websockets Disconnects after first message recieved ESP32 Generic Ethernet WS5

Describe the bug

Using the standard example for Websockets2 Generic, and ESP32 with WZ500 shield as a WebsocketServer, everything works, excepts after first message the server closes the websocket.

Steps to Reproduce

Compile and run the WebsocketServer Example under Generic, ESP32 Ethernet.

Expected behavior

Like with normal Websockets library Links2004
the socket should stay open until client disconnects or server kills the connection.

Actual behavior

Server sends disconnect after first message received.

Information

Please ensure to specify the following, or your post will be ignored and deleted:

This happens on any IDE, PlatformIO and Ardunio IDE.
Using latest espressif32, with platform arduino.
Nothing added, plain example. Tested from Chrome and several other browsers.

This happens on Wifi and Ethernet.

Problem with connecting to a nodejs (socket.io)

Hello Khoih,

The library must have a problem.
Remember that I told you that sometimes, when restarting the servers, the mkr 1000 with ethernet shield and with your library, socket.io could not reconnect with the server, and the only way to make it work again was to turn off the arduino and restart it.
You told me that the problem was the fault of nodejs on ubuntu.
But now I am using the mkr1000 over wifi (wifi101) and the nodejs server is on Windows and I have exactly the same problem, so undoubtedly, the library must have some problem, and in certain circumstances it cannot reconnect with the server.
This is a serious problem and makes your library unusable in an environment that requires connection security.
The difficulty here is the reproduction of this problem, as it occurs at some point, it can happen a few hours or occur immediately, sometimes restarting the server, other times without doing anything special.
It's very complicated.
Do you have any idea to solve it?

Thanks for the help.
Hope you're well.

Regards,
Jose.

SocketIO re-connect does not work

Describe the bug

Using several boards (such as the RP2040 Connect or the MKRWiFi1010) on a WiFi connection (i.e. no Ethernet-shield but pure WiFi), I had to realize that this library's SocketIO re-connect does not work.

Steps to Reproduce

Using a remote Node.js Server (cannot share since our customer does not allow), I made the following observation:

(by the way, very similar to this issue explained here - unfortunately no solution was posted about this issue yet)

  • The remote SocketIO server turns off and turns on
    --> this should lead to a SocketIO re-connect on the Arduino client. But it doesn't !
    --> As a background information: Our remote SocketIO server must be able to turn off and turn on since it is hosted in our case as a Google Cloud Run server. And any Node does disconnect after a maximum time of 3600 seconds (security policy). Therefore we must solve this re-connect issue with the WebSocket_Generic library using SocketIO)

  • For my trials here, I put the remote-server turn off and back-on period to 60 seconds. This gives me many more occasions to observe the Arduino behaviour.

  • So, the remote SocketIO server continues turning off and back on - every 60 seconds. And I can observe that the Arduino's SocketIO DISCCONNECT event is only occurring sporadically (i.e. about every 2nd or 3rd time). This is a wrong and inexplicable behaviour.

Steps to reproduce:

  • turn off and turn on the remote SocketIO server
  • the Arduino Serial Monitor stops showing ping/pong (in fact, it does not show anything after the remote-server turns off/on). It is in an unknown state.
  • the Arduino does not re-connect as it should. It does not even show any kind of SocketIO event (such as DISCONNECT, CLOSE, not any EVENT happens).

Expected behavior

The expected behaviour is that the Arduino SocketIO Client re-connects automatically.

This behaviour is the standard behaviour of Socket IO as described here and here.

Not sure if important - but on the official Socket.io page, it sais Please note that since Socket.IO v3, the Socket instance does not emit any event related to the reconnection logic anymore. You can listen to the events on the Manager instance directly:

socket.io.on("reconnect_attempt", () => {
  // ...
});
socket.io.on("reconnect", () => {
  // ...
});

One more observation:

I am using WiFi to connect. (RP2040 Connect or MKRWiFi1010) and I am using beginSSL(...) to connect with SocketIO.

All that works fine.

Now, when I turn off my WiFi network, I do get a DISCONNECT event inside the Arduino Client.

But I do not get this event when the remote-server turns its node off.

Nano IOT and platform IO "Communication with WiFi module failed!"

Hello,
When running any example on different Nano IOT I noticed that when using platform io you always end up with the message "Communication with WiFi module failed!". This seems to only happen on platform io because the example i used work on arduinoIDE 2.0

The problem seems to be coming from WIFI NINA generic.

To solve this i ended up modifying the #include <WiFiNINA_Generic.h> by <WiFiNINA.h> in WebSockets_Generic.h

PS: you also need to add lib_ignore = DueFlashStorage in platformio.ini to remove a bunch of error when adding the lib to the project

Compile error on Wio Terminal: 'class WiFiClientSecure' has no member named 'setInsecure'

Hi,
I'm just updating a 'Sinric Pro' application for the Wio Terminal from the lib SinricPro_Generic v2.8.0 to v2.8.3 and now get the compilation error from the included WebSockets_Generic library:
.pio\libdeps\SAMD\WebSockets_Generic@src-3e25c04322622ed35619bd8f1cb33dbd\src/WebSocketsClient_Generic-Impl.h:396:22: error: 'class WiFiClientSecure' has no member named
'setInsecure'
_client.ssl->setInsecure();

It's not a big thing and not really a problem for me, but I think that it should not occur and I only wanted to inform about the issue.

PlatformIo Home v3.4.0
Board: Seeed Wio Terminal

Btw: Again many thanks for your valuable work. Lately I used your 'ESPAsync_WiFiManager' in an application (https://github.com/RoSchmi/Esp32_WiFiManager_HeatingSurvey) and it works like a charm.

Best regards
RoSchmi

Socket.io client on Teensy Native Ethernet not working on Websockets_Generic

Describe the bug
Getting compiler warnings, not seeing any packets from Teensy using this code, only modified the IP server address(192.168.1.187) and Port (3000)

Steps to Reproduce
Steps to reproduce the behavior. Including the MRE sketches

Expected behavior
Expected to see TCP packets from teensy on Wireshark

Actual behavior
Can ping teensy, and see the pings on wireshark

Debug and AT-command log (if applicable)
Arduino compiler

Teensy_WebSocketClientSocketIO_NativeEthernet:84: warning: #warning Using NativeEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error 
   #warning Using NativeEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error
    ^
In file included from C:\Users\me\GitHub\Arduino\libraries\WebSockets_Generic\src/WebSocketsClient_Generic.h:56:0,
                 from C:\Users\me\GitHub\Arduino\Teensy_WebSocketClientSocketIO_NativeEthernet\Teensy_WebSocketClientSocketIO_NativeEthernet.ino:126:
C:\Users\me\GitHub\Arduino\libraries\WebSockets_Generic\src/WebSockets_Generic.h:231:4: warning: #warning Use Teensy in WebSockets_Generic [-Wcpp]
   #warning Use Teensy in WebSockets_Generic
    ^
C:\Users\me\GitHub\Arduino\libraries\WebSockets_Generic\src/WebSockets_Generic.h:516:4: warning: #warning Using Teensy 4.1 NativeEthernet Library [-Wcpp]
   #warning Using Teensy 4.1 NativeEthernet Library
    ^
In file included from C:\Users\me\GitHub\Arduino\libraries\WebSockets_Generic\src/WebSockets_Generic.h:718:0,
                 from C:\Users\me\GitHub\Arduino\libraries\WebSockets_Generic\src/WebSocketsClient_Generic.h:56,
                 from C:\Users\me\GitHub\Arduino\Teensy_WebSocketClientSocketIO_NativeEthernet\Teensy_WebSocketClientSocketIO_NativeEthernet.ino:126:
C:\Users\me\GitHub\Arduino\libraries\WebSockets_Generic\src/WebSockets_Generic-Impl.h:74:6: warning: #warning No CORE_HAS_LIBB64 [-Wcpp]
     #warning No CORE_HAS_LIBB64
      ^
In file included from C:\Users\me\GitHub\Arduino\libraries\WebSockets_Generic\src/WebSocketsClient_Generic.h:236:0,
                 from C:\Users\me\GitHub\Arduino\Teensy_WebSocketClientSocketIO_NativeEthernet\Teensy_WebSocketClientSocketIO_NativeEthernet.ino:126:
C:\Users\me\GitHub\Arduino\libraries\WebSockets_Generic\src/WebSocketsClient_Generic-Impl.h:303:4: warning: #warning WEBSOCKETS_NETWORK_TYPE != NETWORK_ESP8266_ASYNC [-Wcpp]
   #warning WEBSOCKETS_NETWORK_TYPE != NETWORK_ESP8266_ASYNC
    ^
C:\Users\me\GitHub\Arduino\libraries\WebSockets_Generic\src/WebSocketsClient_Generic-Impl.h:420:6: warning: #warning Not HAS_SSL [-Wcpp]
     #warning Not HAS_SSL
      ^
C:\Users\me\GitHub\Arduino\libraries\WebSockets_Generic\src/WebSocketsClient_Generic-Impl.h: In member function 'virtual void WebSocketsClient::clientDisconnect(WSclient_t*)':
C:\Users\me\GitHub\Arduino\libraries\WebSockets_Generic\src/WebSocketsClient_Generic-Impl.h:729:20: warning: deleting object of polymorphic class type 'EthernetClient' which has non-virtual destructor might cause undefined behaviour [-Wdelete-non-virtual-dtor]
     delete client->tcp;
                    ^
Opening Teensy Loader...
Memory Usage on Teensy 4.1:
  FLASH: code:235564, data:75072, headers:7276   free for files:7808552
   RAM1: variables:40100, code:95512, padding:2792   free for local variables:385884
   RAM2: variables:12416  free for malloc/new:511872

Teensy serial output:

Start Teensy_WebSocketClientSocketIO_NativeEthernet on TEENSY 4.1 with Custom Ethernet using Teensy 4.1 NativeEthernet Library
WebSockets_Generic v2.7.0
[WS] Board :TEENSY 4.1, setCsPin:10
[WS] Default SPI pinout:
[WS] MOSI:11
[WS] MISO:12
[WS] SCK:13
[WS] SS:10
[WS] =========================
WebSockets Client @ IP address: 192.168.1.117
Connecting to WebSockets Server @ IP address: 192.168.1.187, port: 3000
[WS] WebSockets_Generic v2.7.0
[WS] [wsIOc] found EIO=4 disable EIO ping on client
[IOc] Disconnected
[WS] [wsIOc] Disconnected!
["event_name",{"now":45237}]
[IOc] Disconnected
[WS] [wsIOc] Disconnected!
[IOc] Disconnected
[WS] [wsIOc] Disconnected!
["event_name",{"now":77261}]
[IOc] Disconnected
[WS] [wsIOc] Disconnected!
[IOc] Disconnected
[WS] [wsIOc] Disconnected!
["event_name",{"now":109285}]
[IOc] Disconnected
[WS] [wsIOc] Disconnected!
[IOc] Disconnected
[WS] [wsIOc] Disconnected!
["event_name",{"now":141309}]
[IOc] Disconnected
[WS] [wsIOc] Disconnected!
[IOc] Disconnected
[WS] [wsIOc] Disconnected!
["event_name",{"now":173333}]

Ping:

ping 192.168.1.117

Pinging 192.168.1.117 with 32 bytes of data:
Reply from 192.168.1.117: bytes=32 time=1ms TTL=64
Reply from 192.168.1.117: bytes=32 time=1ms TTL=64
Reply from 192.168.1.117: bytes=32 time=1ms TTL=64
Reply from 192.168.1.117: bytes=32 time=1ms TTL=64

Ping statistics for 192.168.1.117:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 1ms, Maximum = 1ms, Average = 1ms

Wireshark
image

Screenshots
If applicable, add screenshots to help explain your problem.

Information
Please ensure to specify the following:

Arduino IDE version:1.8.15
TeensyDuino: 1.54 Beta9
Contextual information: looking to confirm packets are being sent
Anything that might be relevant in your opinion, such as:
Windows 10, firewall disabled MINGW32_NT-6.2 MPC 1.0.8(0.46/3/2) 2002-12-09 07:58 i686 unknown
Unifi network, Teensy hardwired Ethernet, PC is wifi

Ability to receive the Response HTTP Headers

I see that HTTP headers are populated somewhere in the deep of the library. But from client's side they are not available. Most of them are just technical. But one of the interests is sec-websocket-protocol.
Because as described in RFC 6455 client can send a few desired protocols and the server may choose one of them. But client can not get information on what protocol was chosen by the server.

So it would be really helpful to have a kind of .getHeaders() or similar public method on the WebSocketsClient to get this information or it can be passed back to onWsEvent callback alongside with type, payload and length.

Compatibility with WiFiMulti

Hello,

We're developing an embedded application based on the Pico 2040W and are running the maxgerhardt platform with the earlephilhower Arduino Core with WiFiMulti for connectivity. The wireless connection works as intended but we're having troubles establishing a WebSocket connection to our FastAPI server. We've included your library but had to ignore many dependencies, because otherwise it would not build – is this a normal procedure?

Nonetheless, we try to connect using the following code:

#include <string>
#include <Arduino.h>
#include <WiFi.h>
#include <SPI.h>
#include <ArduinoJson.h>
#include <pico/stdlib.h>
#include <WebSocketsClient_Generic.h>

extern "C" {
  #include <acc_version.h>
}

char* chip_id;
WiFiMulti wifi;
String ip_address;
WebSocketsClient webSocket;

bool wifi_connecting = false;
bool alreadyConnected = false;
unsigned long previous_millis = 0;
const char* WIFI_SSID = "SSID";
const char* WIFI_PASS = "PASS";
const uint WIFI_TIMEOUT = 10; // Timeout in seconds

const uint LED_PIN = 14;
const uint SWITCH_PIN = 13;

const uint SPI_MISO = 16;
const uint SPI_MOSI = 19;
const uint SPI_SCK = 18;
const uint SPI_CS = 17;

const uint SEN_EN1 = 20;
const uint SPI_SEL0 = 22;
const uint SPI_SEL1 = 26;
const uint SPI_SEL2 = 27;
const uint SEN_INT1 = 21;


#if (defined(ARDUINO_RASPBERRY_PI_PICO_W))
  #if defined(WEBSOCKETS_NETWORK_TYPE)
    #undef WEBSOCKETS_NETWORK_TYPE
  #endif
  #define WEBSOCKETS_NETWORK_TYPE       NETWORK_RP2040W_WIFI
  #define _WEBSOCKETS_LOGLEVEL_         10
#else
  #error This code is intended to run only on the RP2040W boards ! Please check your Tools->Board setting.
#endif

/// @brief Ready the SPI pins for communication.
void setup_spi() {
  SPI.setRX(SPI_MISO);
  SPI.setCS(SPI_CS); // Documentation says this should be set to high??
  SPI.setSCK(SPI_SCK); // Might need to be high...
  SPI.setTX(SPI_MOSI);
  SPI.begin();
}

void setup_gpio() {
  gpio_init(LED_PIN);
  gpio_init(SWITCH_PIN);
  gpio_set_dir(LED_PIN, GPIO_OUT);
  gpio_set_dir(SWITCH_PIN, GPIO_IN);

  // XE121 pins
  gpio_init(SEN_EN1);
  gpio_init(SPI_SEL0);
  gpio_init(SPI_SEL1);
  gpio_init(SPI_SEL2);
  gpio_init(SEN_INT1);

  // XE121 pin types
  gpio_set_dir(SEN_EN1, GPIO_OUT);
  gpio_set_dir(SPI_SEL0, GPIO_OUT);
  gpio_set_dir(SPI_SEL1, GPIO_OUT);
  gpio_set_dir(SPI_SEL2, GPIO_OUT);
  gpio_set_dir(SEN_INT1, GPIO_IN);

  // XE121 pin defaults
  gpio_put(SEN_EN1, 0);
  gpio_put(SPI_SEL0, 1); // Select sensor 2 according to table in paragraph 2.6
  gpio_put(SPI_SEL1, 0);
  gpio_put(SPI_SEL2, 0);
}

/// @brief Connect to the network.
void connect_to_wifi() {
  wifi_connecting = true;
  if (wifi.run((WIFI_TIMEOUT * 1000)) != WL_CONNECTED) {
    Serial.println("Unable to connect to Wi-Fi, rebooting device in 10 seconds...");
    delay(10000);
    rp2040.reboot();
  } else {
    wifi_connecting = false;
    ip_address = WiFi.localIP().toString();
    Serial.println("Successfully connected to network " + WiFi.softAPSSID());
    Serial.println("Device IP address: " + ip_address);
  }
}

void webSocketEvent(const WStype_t& type, uint8_t * payload, const size_t& length) {
  switch (type) {
    case WStype_DISCONNECTED:
      if (alreadyConnected) {
        Serial.println("[WSc] Disconnected!");
        alreadyConnected = false;
      }
      
      break;
      
    case WStype_CONNECTED:
      {
        alreadyConnected = true;
        
        Serial.print("[WSc] Connected to url: ");
        Serial.println((char *) payload);

        // send message to server when Connected
        webSocket.sendTXT("Connected");
      }
      
      break;
      
    case WStype_TEXT:
      Serial.print("[WSc] get text: ");
      Serial.println((char *) payload);

      // send message to server
       webSocket.sendTXT("message here");
       
      break;
      
    case WStype_BIN:
      Serial.print("[WSc] get binary length: ");
      Serial.println(length);
      
      // KH, To check
      // hexdump(payload, length);

      // send data to server
      webSocket.sendBIN(payload, length);
      
      break;

    case WStype_PING:
      // pong will be send automatically
      Serial.println("[WSc] get ping");
      
      break;
      
    case WStype_PONG:
      // answer to a ping we send
      Serial.println("[WSc] get pong");
      
      break;

    default:
      break;
  }
}

void setup() {
  Serial.begin(9600);

  // Fetch chip id:
  chip_id = (char*) rp2040.getChipID();

  // Check for the WiFi module:
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("Communication with WiFi module failed!");
    // don't continue
    while (true);
  }

  // Set hostname:
  WiFi.setHostname(chip_id);

  // Register networks:
  wifi.addAP(WIFI_SSID, WIFI_PASS);

  connect_to_wifi();

  String path = (String) "/ws/" + (String) chip_id;
  IPAddress host = IPAddress(192, 168, 1, 212);
  Serial.println(path);
  Serial.println(host.toString());
  webSocket.begin(host, 8000, path);
  webSocket.onEvent(webSocketEvent);

  setup_gpio();
  setup_spi();
}

void loop() {
  unsigned long current_millis = millis();
  
  if (current_millis - previous_millis >= 5000) {
    previous_millis = current_millis;
    String version = acc_version_get();
    Serial.println("Acconeer SDK version: " + version);
  }

  uint led_state = gpio_get(SWITCH_PIN);
  gpio_put(LED_PIN, led_state);

  if (!WiFi.connected() && !wifi_connecting) {
    Serial.println("Lost connection to Wi-Fi. Attempting to reconnect...");
    connect_to_wifi();
  }

  webSocket.loop();

  delay(25);
}

The code runs, but I never reach a state where it prints anything, and when I check webSocket.isConnected() it returns false. My question is – could this have to do with our Wi-Fi library, or simply because it's unable to connect?

The websocket endpoint is currently hosted on a local device at 192.168.1.212:8000/ws({device_id}. I'm able to connect to this endpoint just fine using Postman or other Websocket programs, but not through this library.

Any help is greatly appreciated! ❤️

Thanks,
Jonathan

Major issue with WiFiNINA - Arduino IoT 33

Try to run the example Generic_WebSocketServer_WiFiNINA on my Arduino IoT 33.
It connects to my Home wifi, then it just starts spamming the DISCONNECTED event:

08:53:46.281 -> Start Generic_WebSocketServer_WiFiNINA
08:53:46.281 -> Used/default SPI pinout:
08:53:46.281 -> MOSI:11
08:53:46.281 -> MISO:12
08:53:46.281 -> SCK:13
08:53:46.281 -> SS:10
08:53:46.281 -> [SETUP] BOOT WAIT 4
08:53:47.300 -> [SETUP] BOOT WAIT 3
08:53:48.283 -> [SETUP] BOOT WAIT 2
08:53:49.279 -> [SETUP] BOOT WAIT 1
08:53:51.055 -> Please upgrade the firmware
08:53:51.055 -> Attempting to connect to SSID: Home
08:53:55.723 -> WiFi-begin: return1 = 3
08:53:55.723 -> WiFi-begin: return2 = 3
08:53:55.723 -> SSID: Home
08:53:55.723 -> WebSockets Server IP address: 192.168.68.110
08:53:55.723 -> signal strength (RSSI):-77 dBm
08:53:55.723 -> [0] Disconnected!
08:53:55.723 -> [0] Disconnected!
08:53:55.723 -> [0] Disconnected!
08:53:55.723 -> [0] Disconnected!
08:53:55.723 -> [0] Disconnected!
08:53:55.723 -> [0] Disconnected!
08:53:55.723 -> [0] Disconnected!
08:53:55.723 -> [0] Disconnected!
08:53:55.723 -> [0] Disconnected!
08:53:55.723 -> [0] Disconnected!
08:53:55.723 -> [0] Disconnected!
08:53:55.723 -> [0] Disconnected!

It continues like that until arduino ide just crashes.
I'm not even trying to connect another device at this point, cos i can't.
Can you please help with this issue? I found this library has a lot of potential but i can't use it. Or maybe i can contribute if you point me in the right direction, thanks.

Arduino Mega + W5500

What mods should i do to compile that Library?

I'm getting error "AVR Not supported"
"Get atmega branch"

[Question]

I need to use ESP32 as a websocket over ethernet without wifi.
The environment cannot use wifi.
I need a websocket connection from my laptop to ESP32 via ethernet.
How can this be possible?
Even if I try to change the example, the server is connected and the web page is loaded, but the websocket cannot be connected.

Thank you in advance.

#include <SPI.h>
#include <Ethernet.h>
#include <EthernetWebServer.h>
#include <WebSocketsServer_Generic.h>
EthernetWebServer server(80);
WebSocketsServer webSocket = WebSocketsServer(81);

void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length)
{
  switch (type)
  {
    case WStype_DISCONNECTED:
      Serial.println( "[" + String(num) + "] Disconnected!");
      break;
    case WStype_CONNECTED:
      {
        IPAddress ip = webSocket.remoteIP(num);
        Serial.printf("[%u] Connected from %d.%d.%d.%d url: %s\n", num, ip[0], ip[1], ip[2], ip[3], payload);

        // send message to client
        webSocket.sendTXT(num, "Connected");
      }
      break;
    case WStype_TEXT:
      Serial.println( "[" + String(num) + "] get Text: " + String((char *) payload));

      if (payload[0] == '#')
      {
        // we get RGB data

        // decode rgb data
        uint32_t rgb = (uint32_t) strtol((const char *) &payload[1], NULL, 16);
      }
      break;

    default:
      break;
  }
}

void setup() {
  WiFi.mode(WIFI_AP_STA);  //Infinite reboot prevention
  Serial.begin(115200);
  Ethernet.init (5);
  byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
  Ethernet.begin(mac);
  Serial.print("WebSockets Server @ IP address: ");
  Serial.println(Ethernet.localIP());

  webSocket.begin();
  webSocket.onEvent(webSocketEvent);
  server.on("/", []()
  {
    // send index.html
    server.send(200, "text/html", "<html><head><script>var connection = new WebSocket('ws://'+location.hostname+':81/', ['arduino']); connection.onopen = function () {  connection.send('Connect ' + new Date()); }; connection.onerror = function (error) {    console.log('WebSocket Error ', error);};connection.onmessage = function (e) {  console.log('Server: ', e.data);};function sendRGB() {  var r = parseInt(document.getElementById('r').value).toString(16);  var g = parseInt(document.getElementById('g').value).toString(16);  var b = parseInt(document.getElementById('b').value).toString(16);  if(r.length < 2) { r = '0' + r; }   if(g.length < 2) { g = '0' + g; }   if(b.length < 2) { b = '0' + b; }   var rgb = '#'+r+g+b;    console.log('RGB: ' + rgb); connection.send(rgb); }</script></head><body>LED Control:<br/><br/>R: <input id=\"r\" type=\"range\" min=\"0\" max=\"255\" step=\"1\" oninput=\"sendRGB();\" /><br/>G: <input id=\"g\" type=\"range\" min=\"0\" max=\"255\" step=\"1\" oninput=\"sendRGB();\" /><br/>B: <input id=\"b\" type=\"range\" min=\"0\" max=\"255\" step=\"1\" oninput=\"sendRGB();\" /><br/></body></html>");
  });
  server.begin();
}

void loop()
{
  unsigned long t = millis();
  webSocket.loop();
  server.handleClient();
}

PN20-1357

WT32-ETH01 Socket.IO connects then immediately disconnects.

Describe the bug

When I use the example WT32_ETH01_WebSocketClientSocketIO.ino example to connect to my node.js server the Serial Monitor shows:

[WS] [WS-Client] Connect ws...
[IOc] Disconnected

Steps to Reproduce

  1. Use WT32-ETH01 board with a USB CP2102
  2. Install all the libraries needed for the sketch and setup a basic node.js socket.io server.
  3. Run it.

Expected behavior

It successfully connecting to my node.js server.

Actual behavior

Gets immediately disconnected and tries over and over again.

Screenshots

https://imgur.com/a/xhvCU39

The serial monitor.

Information

Arduino IDE version: 2.0.3
Chip: Wireless Tag WT32-S1
Board: Wireless Tag WT32-ETH01 + CP2102
OS: Windows 10

###Code

**WT32-ETH01 code**
/****************************************************************************************************************************
  WT32_ETH01_WebSocketClientSocketIO.ino
  For WT32_ETH01
  Based on and modified from WebSockets libarary https://github.com/Links2004/arduinoWebSockets
  to support other boards such as  SAMD21, SAMD51, Adafruit's nRF52 boards, etc.
  Built by Khoi Hoang https://github.com/khoih-prog/WebSockets_Generic
  Licensed under MIT license
  Originally Created on: 24.05.2015
  Original Author: Markus Sattler
*****************************************************************************************************************************/

#if !defined(ESP32)
  #error This code is intended to run only on the ESP32 boards ! Please check your Tools->Board setting.
#endif

#define _WEBSOCKETS_LOGLEVEL_     2

// For transport=websocket instead of transport=polling
#define USING_STICKY_SESSION_SIO        true

#include <WebServer_WT32_ETH01.h>     // https://github.com/khoih-prog/WebServer_WT32_ETH01

#include <ArduinoJson.h>

#include <WebSocketsClient_Generic.h>
#include <SocketIOclient_Generic.h>

SocketIOclient socketIO;

/////////////////////////////////////////////

// Select the Server's IP address according to your local network
IPAddress serverIP(192, 168, 100, 59);
uint16_t  serverPort = 8080;

/////////////////////////////////////////////

// Select the IP address according to your local network
IPAddress myIP(192, 168, 100, 59);
IPAddress myGW(192, 168, 100, 1);
IPAddress mySN(255, 255, 255, 0);

// Google DNS Server IP
IPAddress myDNS(8, 8, 8, 8);

/////////////////////////////////////////////

void hexdump(const void *mem, const uint32_t& len, const uint8_t& cols = 16)
{
  const uint8_t* src = (const uint8_t*) mem;

  Serial.printf("\n[HEXDUMP] Address: 0x%08X len: 0x%X (%d)", (ptrdiff_t)src, len, len);

  for (uint32_t i = 0; i < len; i++)
  {
    if (i % cols == 0)
    {
      Serial.printf("\n[0x%08X] 0x%08X: ", (ptrdiff_t)src, i);
    }

    Serial.printf("%02X ", *src);
    src++;
  }

  Serial.printf("\n");
}

void socketIOEvent(const socketIOmessageType_t& type, uint8_t * payload, const size_t& length)
{
  switch (type)
  {
    case sIOtype_DISCONNECT:
      Serial.println("[IOc] Disconnected");

      break;

    case sIOtype_CONNECT:
      Serial.print("[IOc] Connected to url: ");
      Serial.println((char*) payload);

      // join default namespace (no auto join in Socket.IO V3)
      socketIO.send(sIOtype_CONNECT, "/");

      break;

    case sIOtype_EVENT:
      Serial.print("[IOc] Get event: ");
      Serial.println((char*) payload);

      break;

    case sIOtype_ACK:
      Serial.print("[IOc] Get ack: ");
      Serial.println(length);

      hexdump(payload, length);

      break;

    case sIOtype_ERROR:
      Serial.print("[IOc] Get error: ");
      Serial.println(length);

      hexdump(payload, length);

      break;

    case sIOtype_BINARY_EVENT:
      Serial.print("[IOc] Get binary: ");
      Serial.println(length);

      hexdump(payload, length);

      break;

    case sIOtype_BINARY_ACK:
      Serial.print("[IOc] Get binary ack: ");
      Serial.println(length);

      hexdump(payload, length);

      break;

    case sIOtype_PING:
      Serial.println("[IOc] Get PING");

      break;

    case sIOtype_PONG:
      Serial.println("[IOc] Get PONG");

      break;

    default:
      break;
  }
}

void setup()
{
  // Serial.begin(921600);
  Serial.begin(115200);

  while (!Serial);

  Serial.print("\nStart WT32_ETH01_WebSocketClient_Sticky_SocketIO on ");
  Serial.print(ARDUINO_BOARD);
  Serial.print(" with ");
  Serial.println(SHIELD_TYPE);
  Serial.println(WEBSERVER_WT32_ETH01_VERSION);
  Serial.println(WEBSOCKETS_GENERIC_VERSION);

  Serial.setDebugOutput(true);

  // To be called before ETH.begin()
  WT32_ETH01_onEvent();

  //bool begin(uint8_t phy_addr=ETH_PHY_ADDR, int power=ETH_PHY_POWER, int mdc=ETH_PHY_MDC, int mdio=ETH_PHY_MDIO,
  //           eth_phy_type_t type=ETH_PHY_TYPE, eth_clock_mode_t clk_mode=ETH_CLK_MODE);
  //ETH.begin(ETH_PHY_ADDR, ETH_PHY_POWER, ETH_PHY_MDC, ETH_PHY_MDIO, ETH_PHY_TYPE, ETH_CLK_MODE);
  ETH.begin(ETH_PHY_ADDR, ETH_PHY_POWER);

  // Static IP, leave without this line to get IP via DHCP
  //bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = 0, IPAddress dns2 = 0);
  ETH.config(myIP, myGW, mySN, myDNS);

  WT32_ETH01_waitForConnect();

  // Client address
  Serial.print("WebSockets Client started @ IP address: ");
  Serial.println(ETH.localIP());

  // server address, port and URL
  Serial.print("Connecting to WebSockets Server @ IP address: ");
  Serial.print(serverIP);
  Serial.print(", port: ");
  Serial.println(serverPort);

  // setReconnectInterval to 10s, new from v2.5.1 to avoid flooding server. Default is 0.5s
  socketIO.setReconnectInterval(10000);

  socketIO.setExtraHeaders("Authorization: 1234567890");

  // server address, port and URL
  // void begin(IPAddress host, uint16_t port, String url = "/socket.io/?EIO=4", String protocol = "arduino");
  // To use default EIO=4 fron v2.5.1
  socketIO.begin(serverIP, serverPort);

  // event handler
  socketIO.onEvent(socketIOEvent);
}

unsigned long messageTimestamp = 0;

void loop()
{
  socketIO.loop();

  uint64_t now = millis();

  if (now - messageTimestamp > 30000)
  {
    messageTimestamp = now;

    // creat JSON message for Socket.IO (event)
    DynamicJsonDocument doc(1024);
    JsonArray array = doc.to<JsonArray>();

    // add evnet name
    // Hint: socket.on('event_name', ....
    array.add("event_name");

    // add payload (parameters) for the event
    JsonObject param1 = array.createNestedObject();
    param1["now"]     = (uint32_t) now;

    // JSON to String (serializion)
    String output;
    serializeJson(doc, output);

    // Send event
    socketIO.sendEVENT(output);

    // Print JSON for debugging
    Serial.println(output);
  }
}

Node.js webserver side code:

const express = require('express')
const app = express()
const http = require('http').Server(app);
const io = require('socket.io')(http);
const port = process.env.PORT || 8080;



app.use(express.static('public'))

app.get('/', (req, res) => {
  res.sendFile(__dirname + '/index.html');
});

io.on('connection', (socket) => {
  console.log('a user connected');
  socket.on('disconnect', () => {
    console.log('user disconnected');
    
  


  });

  socket.on("AX1", (AX1d) => {
   io.emit('AX1R', (AX1d))
  })

  
});

I am really sorry if I missed anything obvious, Its something I've done on my end but cant figure out sorry, hope this doesnt waste too much of your time.

ESP32 + W5500 Test example

Hello, thank you for your efforts in creating this library
My project uses the ESP32 + W5500 module and the Websocket protocol.
I'm looking to use your library but it's confusing to me.
Which WebSockets2_Generic or WebSockets_Generic exactly?
Which ethernet Libraries should be selected ?! Ethernet2.h or EthernetLarge.h
Also, which example should be tested? Is there a roadmap?

thank you

No free space new client / Counting of clients wrong?

Try to setup a web socket server with wifinina.

When I try the example Generic_WebSocketServer_WiFiNINA.ino the
websocket connection is always closed. I try to connect with different clients.
As far I can see the MKR WiFi 1010 should be supported since version 2.1.3.

It looks for me that the counting of the clients is not correct. I try to open only
one connection. See the log.

Wifi-version:
WiFiNINA firmware check.
Firmware version installed: 1.3.0
Latest firmware version available : 1.3.0
Check result: PASSED

websockets generic version: 2.2.2

[WS] 0 new client
[WS] 0 [handleHeader] RX: GET / HTTP/1.1
[WS] 1 new client
[WS] 0 [handleHeader] RX: Host: 10.X.X.X:81
[WS] 1 [handleHeader] RX: User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:77.0) Gecko/20100101 Firefox/77.0
[WS] 2 new client
[WS] 0 [handleHeader] RX: Accept: /
[WS] 1 [handleHeader] RX: Accept-Language: de,en-US;q=0.7,en;q=0.3
[WS] 2 [handleHeader] RX: Accept-Encoding: gzip, deflate
[WS] 3 new client
[WS] 0 [handleHeader] RX: Sec-WebSocket-Version: 13
[WS] 1 [handleHeader] RX: Origin: moz-extension://79922fef-6785-6549-9f19-3efc822c7d29
[WS] 2 [handleHeader] RX: Sec-WebSocket-Protocol: arduino
[WS] 3 [handleHeader] RX: Sec-WebSocket-Extensions: permessage-deflate
[WS] 4 new client
[WS] 0 [handleHeader] RX: Sec-WebSocket-Key: 3yzKvswNEXx9sBqgHUK7qw==
[WS] 1 [handleHeader] RX: Connection: keep-alive, Upgrade
[WS] 2 [handleHeader] RX: Pragma: no-cache
[WS] 3 [handleHeader] RX: Cache-Control: no-cache
[WS] 4 [handleHeader] RX: Upgrade: websocket
[WS] [WS-Server] No free space new client
[WS] 0 client connection lost
[WS] 0 client disconnected.

Loss of connection of the arduino MKR with the nodejs server when the nodejs server is restarted.

Hello Khoih,

We haven't spoken for a long time, I hope you are feeling very well.

I have a serious problem with socket.io, as you know I am using nodejs as a server and an Arduino MKR1000.
I have observed the following bug, when I turn off the nodejs and then run it, an automatic reconnection of the arduinos to the nodejs generally occurs, however, this does not always happen, on many occasions, the arduino does not reconnect with the nodejs server and I have no choice but to turn the arduinos power off and turn them back power on.
I also have a web application created with Flutter and that uses socket.io that does not have this problem, so it is obviously a problem with the websockets_generic library.
Would you have any idea how to solve this problem?

Thank you very much for your help.

Regards,
Jose A.Molina

Just wondering how exactly the client will receive the event from the socket.io server.

Hey Khoi!

Cheers for helping me earlier, I got it working now, seemed to be an issue with how I portfowarded of sorts. Not really an issue here just need clarification. I am quite new to arduino and this might seem obvious, but im having a bit of a hard time understanding how exactly.

Say my server is emitting the event.

io.emit("Event", ("Hello World!"))

Which one of the arguments should I use to get it to print out the event? From what I've seen you need the call the event before you declare it on the ESP32 side, this got my bewildered as a normal client on socket.io doesnt declare the event before it happens. In the documentation I saw these two referred:

void (*WebSocketClientEvent)(WStype_t type, uint8_t * payload, size_t length)

And

void onEvent(WebSocketClientEvent cbEvent);

Callback is the data of the event right? Which one of these two would you use for it to detect the event named "Event" and for it to print the "Hello World!" string, and how does the client know which event to respond to. On sockets.io when you program a client tradionally you simply just use the socket.io function

Cheers and thanks in advance, I'm sorry is this is a stupidly obvious question.

WT32-ETH01 connects for about 90 seconds then suddenly disconnects, cant figure out why.

I am absolutely bewildered right now, I have been using this library WebSocket_generic for my WT32-ETH01 and ive been using its examples just to check for a connection. Ive used both the server and client examples, it connects just fine, but after three messages, or roughly 90 secs give or take it suddenly and abruptly disconnects. Give it 5 minutes it reconnects, sends some more pings and it disconnects, and does so in a cycle. Here is the serverside code:

Server side code:

io.on('connection', (socket) => {

  console.log('Connected');
  console.log(socket.id);
  console.log("JWT token test: ",socket.handshake.headers)

  socket.on('event_name', (data) => {

    console.log("Message from Client : ", data);

    socket.broadcast.emit("Send Message socket.broadcast.emit : ", data);
    io.emit("Send Message io.emit Broadcasted : ", data);
    socket.emit("Send Message : ", data);

  })
  
  socket.on('disconnect', (reason) => {

    console.log('Disconnected');
    console.log(reason);

  })

})



http.listen(8080, () => {

  console.log("Server launched on port 8080");
})

WT32-ETH01 code

#if !defined(ESP32)
  #error This code is intended to run only on the ESP32 boards ! Please check your Tools->Board setting.
#endif

#define _WEBSOCKETS_LOGLEVEL_     2

#include <WebServer_WT32_ETH01.h>     // https://github.com/khoih-prog/WebServer_WT32_ETH01

#include <ArduinoJson.h>

#include <WebSocketsClient_Generic.h>
#include <SocketIOclient_Generic.h>

SocketIOclient socketIO;

/////////////////////////////////////////////

// Select the Server's IP address according to your local network
IPAddress serverIP(192, 168, 100, 59);
uint16_t  serverPort = 8080;

/////////////////////////////////////////////

// Select the IP address according to your local network
IPAddress myIP(192, 168, 100, 99);
IPAddress myGW(192, 168, 100, 1);
IPAddress mySN(255, 255, 255, 0);

// Google DNS Server IP
IPAddress myDNS(8, 8, 8, 8);

/////////////////////////////////////////////

void hexdump(const void *mem, const uint32_t& len, const uint8_t& cols = 16)
{
  const uint8_t* src = (const uint8_t*) mem;

  Serial.printf("\n[HEXDUMP] Address: 0x%08X len: 0x%X (%d)", (ptrdiff_t)src, len, len);

  for (uint32_t i = 0; i < len; i++)
  {
    if (i % cols == 0)
    {
      Serial.printf("\n[0x%08X] 0x%08X: ", (ptrdiff_t)src, i);
    }

    Serial.printf("%02X ", *src);
    src++;
  }

  Serial.printf("\n");
}

void socketIOEvent(const socketIOmessageType_t& type, uint8_t * payload, const size_t& length)
{
  switch (type)
  {
    case sIOtype_DISCONNECT:
      Serial.println("[IOc] Disconnected");

      break;

    case sIOtype_CONNECT:
      Serial.print("[IOc] Connected to url: ");
      Serial.println((char*) payload);

      // join default namespace (no auto join in Socket.IO V3)
      socketIO.send(sIOtype_CONNECT, "/");

      break;

    case sIOtype_EVENT:
      Serial.print("[IOc] Get event: ");
      Serial.println((char*) payload);

      break;

    case sIOtype_ACK:
      Serial.print("[IOc] Get ack: ");
      Serial.println(length);

      hexdump(payload, length);

      break;

    case sIOtype_ERROR:
      Serial.print("[IOc] Get error: ");
      Serial.println(length);

      hexdump(payload, length);

      break;

    case sIOtype_BINARY_EVENT:
      Serial.print("[IOc] Get binary: ");
      Serial.println(length);

      hexdump(payload, length);

      break;

    case sIOtype_BINARY_ACK:
      Serial.print("[IOc] Get binary ack: ");
      Serial.println(length);

      hexdump(payload, length);

      break;

    case sIOtype_PING:
      Serial.println("[IOc] Get PING");

      break;

    case sIOtype_PONG:
      Serial.println("[IOc] Get PONG");

      break;

    default:
      break;
  }
}

void setup()
{
  // Serial.begin(921600);
  Serial.begin(115200);

  while (!Serial);

  Serial.print("\nStart WT32_ETH01_WebSocketClientSocketIO on ");
  Serial.print(ARDUINO_BOARD);
  Serial.print(" with ");
  Serial.println(SHIELD_TYPE);
  Serial.println(WEBSERVER_WT32_ETH01_VERSION);
  Serial.println(WEBSOCKETS_GENERIC_VERSION);

  Serial.setDebugOutput(true);

  // To be called before ETH.begin()
  WT32_ETH01_onEvent();

  //bool begin(uint8_t phy_addr=ETH_PHY_ADDR, int power=ETH_PHY_POWER, int mdc=ETH_PHY_MDC, int mdio=ETH_PHY_MDIO,
  //           eth_phy_type_t type=ETH_PHY_TYPE, eth_clock_mode_t clk_mode=ETH_CLK_MODE);
  //ETH.begin(ETH_PHY_ADDR, ETH_PHY_POWER, ETH_PHY_MDC, ETH_PHY_MDIO, ETH_PHY_TYPE, ETH_CLK_MODE);
  ETH.begin(ETH_PHY_ADDR, ETH_PHY_POWER);

  // Static IP, leave without this line to get IP via DHCP
  //bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = 0, IPAddress dns2 = 0);
  ETH.config(myIP, myGW, mySN, myDNS);

  WT32_ETH01_waitForConnect();

  // Client address
  Serial.print("WebSockets Client started @ IP address: ");
  Serial.println(ETH.localIP());

  // server address, port and URL
  Serial.print("Connecting to WebSockets Server @ IP address: ");
  Serial.print(serverIP);
  Serial.print(", port: ");
  Serial.println(serverPort);

  // setReconnectInterval to 10s, new from v2.5.1 to avoid flooding server. Default is 0.5s
  socketIO.setReconnectInterval(10000);

  socketIO.setExtraHeaders("Authorization: 1234567890");

  // server address, port and URL
  // void begin(IPAddress host, uint16_t port, String url = "/socket.io/?EIO=4", String protocol = "arduino");
  // To use default EIO=4 fron v2.5.1
  socketIO.begin(serverIP, serverPort);

  // event handler
  socketIO.onEvent(socketIOEvent);
}

unsigned long messageTimestamp = 0;

void loop()
{
  socketIO.loop();

  uint64_t now = millis();

  if (now - messageTimestamp > 30000)
  {
    messageTimestamp = now;

    // creat JSON message for Socket.IO (event)
    DynamicJsonDocument doc(1024);
    JsonArray array = doc.to<JsonArray>();

    // add evnet name
    // Hint: socket.on('event_name', ....
    array.add("event_name");

    // add payload (parameters) for the event
    JsonObject param1 = array.createNestedObject();
    param1["now"]     = (uint32_t) now;

    // JSON to String (serializion)
    String output;
    serializeJson(doc, output);

    // Send event
    socketIO.sendEVENT(output);

    // Print JSON for debugging
    Serial.println(output);
  }
}

I am lost, ive used different socket.io verisions such as v1, v2, v3 and v4.

What I expect to happen is for it to have a stable connection, it connects but it disconnects after a short while.

RX:HTTP/1.1 400 Bad Request

hello,

First of all, I would like to thank you for creating such a great library.
Using this library, I am getting RX:HTTP/1.1 400 Bad Request from the server.

I am using DOIT ESP32 DEVKIT VERSION1
IDE: Arduino IDE version: 1.8.16
to experiment the socket IO communication, I used your library. From your library I burnt the code for server into one of the esp32 and obtained its IP address
I used another esp32 and burnt the websocketclientsocketIOack code with changes in the servers' IP address. (The IP address of my server ESP32)
after burning this client code into another esp32, this client esp32 try to connect with the server esp32.
from the serial monitor of server esp32, its showing me [0]Disconnected.
from the serial monitor of client esp32, its displaying me client information along with server response.
in the server response, I see this RX:HTTP/1.1 400 Bad Request

c1.txt

6:32:37.668 -> .
16:32:45.340 -> WebSockets Client started @ IP address: 192.168.1.245
16:32:45.340 -> Connecting to WebSockets Server @ IP address: 192.168.1.213, port: 8080
16:32:45.340 -> [WS] [WS-Client] beginSocketIO with IPAddress
16:32:45.380 -> [WS] [WS-Client] beginSocketIO with const char
16:32:45.380 -> [WS] WebSockets_Generic v2.16.1
16:32:45.380 -> [WS] [wsIOc] found EIO=4 disable EIO ping on client
16:32:45.380 -> [WS] [WS-Client] Connect ws...
16:32:45.380 -> [WS] [WS-Client] Calling _client.tcp->connect, _host =192.168.1.213, port =8080
16:32:45.834 -> [WS] [WS-Client] Calling _client.tcp->connect, _connectResult =1
16:32:45.834 -> [WS] [WS-Client] connectedCb
16:32:45.834 -> [WS] [WS-Client][connectedCb] Connected to Host:192.168.1.213, Port:8080
16:32:45.874 -> [WS] [WS-Client] [sendHeader] Sending header...
16:32:45.874 -> [WS] sendHeader: client->cKey = wz+rHCdIaB1udjEpbCx9AQ==
16:32:45.874 -> [WS] [WS-Client] [sendHeader] Handshake:GET /socket.io/?EIO=4&transport=polling HTTP/1.1
16:32:45.874 -> Host: 192.168.1.213:8080
16:32:45.874 -> Connection: keep-alive
16:32:45.874 -> Authorization: 1234567890
16:32:45.874 -> User-Agent: arduino-WebSocket-Client
16:32:45.874 ->
16:32:45.874 ->
16:32:45.874 -> [WS] [write] n:167, t:19072
16:32:45.874 -> [WS] [write] Write, Length :167, Left :0
16:32:45.874 -> [WS] [WS-Client] [sendHeader] Sending header... Done (us):23347
16:32:45.956 -> [WS] [WS-Client][handleHeader] RX:HTTP/1.1 400 Bad Request
16:32:45.956 -> [WS] [WS-Client][handleHeader] RX:Server: arduino-WebSocket-Server
16:32:45.956 -> [WS] [WS-Client][handleHeader] RX:Content-Type: text/plain
16:32:45.956 -> [WS] [WS-Client] connection lost.
16:32:45.956 -> [WS] [WS-Client] client disconnected.
16:32:45.956 -> [IOc] Disconnected
16:32:45.956 -> [WS] [wsIOc] Disconnected!
16:32:55.958 -> [WS] [WS-Client] Connect ws...
16:32:55.958 -> [WS] [WS-Client] Calling _client.tcp->connect, _host =192.168.1.213, port =8080
16:32:56.164 -> [WS] [WS-Client] Calling _client.tcp->connect, _connectResult =1
16:32:56.164 -> [WS] [WS-Client] connectedCb
16:32:56.164 -> [WS] [WS-Client][connectedCb] Connected to Host:192.168.1.213, Port:8080
16:32:56.164 -> [WS] [WS-Client] [sendHeader] Sending header...
16:32:56.206 -> [WS] sendHeader: client->cKey = AaNvO5QrrsCVvHSC7b/VSw==
16:32:56.206 -> [WS] [WS-Client] [sendHeader] Handshake:GET /socket.io/?EIO=4&transport=polling HTTP/1.1
16:32:56.206 -> Host: 192.168.1.213:8080
16:32:56.206 -> Connection: keep-alive
16:32:56.206 -> Authorization: 1234567890
16:32:56.206 -> User-Agent: arduino-WebSocket-Client
16:32:56.206 ->
16:32:56.206 ->
16:32:56.206 -> [WS] [write] n:167, t:29396
16:32:56.206 -> [WS] [write] Write, Length :167, Left :0
16:32:56.206 -> [WS] [WS-Client] [sendHeader] Sending header... Done (us):23192
16:32:56.810 -> ["event_name",{"now":30001}]
16:33:01.194 -> [WS] [WS-Client][handleClientData] Header response timeout.. Disconnecting!
16:33:01.235 -> [WS] [WS-Client] client disconnected.
16:33:01.235 -> [IOc] Disconnected
16:33:01.235 -> [WS] [wsIOc] Disconnected!
16:33:11.210 -> [WS] [WS-Client] Connect ws...
16:33:11.210 -> [WS] [WS-Client] Calling _client.tcp->connect, _host =192.168.1.213, port =8080
16:33:11.416 -> [WS] [WS-Client] Calling _client.tcp->connect, _connectResult =1
16:33:11.416 -> [WS] [WS-Client] connectedCb
16:33:11.416 -> [WS] [WS-Client][connectedCb] Connected to Host:192.168.1.213, Port:8080
16:33:11.456 -> [WS] [WS-Client] [sendHeader] Sending header...
16:33:11.456 -> [WS] sendHeader: client->cKey = VqIZiDmtu2QgR7VvdjoaQA==
16:33:11.456 -> [WS] [WS-Client] [sendHeader] Handshake:GET /socket.io/?EIO=4&transport=polling HTTP/1.1
16:33:11.456 -> Host: 192.168.1.213:8080
16:33:11.456 -> Connection: keep-alive
16:33:11.456 -> Authorization: 1234567890
16:33:11.456 -> User-Agent: arduino-WebSocket-Client
16:33:11.456 ->
16:33:11.456 ->
16:33:11.456 -> [WS] [write] n:167, t:44652
16:33:11.456 -> [WS] [write] Write, Length :167, Left :0
16:33:11.456 -> [WS] [WS-Client] [sendHeader] Sending header... Done (us):23144
16:33:11.629 -> [WS] [WS-Client][handleHeader] RX:HTTP/1.1 400 Bad Request
16:33:11.629 -> [WS] [WS-Client] connection lost.
16:33:11.629 -> [WS] [WS-Client] client disconnected.
16:33:11.629 -> [IOc] Disconnected
16:33:11.629 -> [WS] [wsIOc] Disconnected!

I am unable to understand what mistake is happening.

Another try I made is to connect with another socket IO server which was created using DJANGO framework.
and its response is as below.

c2.txt

17:18:34.445 -> Connecting to WebSockets Server @ IP address: 44.201.229.255, port: 5051
17:18:34.445 -> [WS] [WS-Client] beginSocketIO with IPAddress
17:18:34.445 -> [WS] [WS-Client] beginSocketIO with const char
17:18:34.445 -> [WS] WebSockets_Generic v2.16.1
17:18:34.445 -> [WS] [wsIOc] found EIO=4 disable EIO ping on client
17:18:34.445 -> [WS] [WS-Client] Connect ws...
17:18:34.445 -> [WS] [WS-Client] Calling client.tcp->connect, host =44.201.229.255, port =5051
17:18:35.149 -> [WS] [WS-Client] Calling client.tcp->connect, connectResult =1
17:18:35.194 -> [WS] [WS-Client] connectedCb
17:18:35.194 -> [WS] [WS-Client][connectedCb] Connected to Host:44.201.229.255, Port:5051
17:18:35.194 -> [WS] [WS-Client] [sendHeader] Sending header...
17:18:35.194 -> [WS] sendHeader: client->cKey = yuspF1pH/C5irr/l5UGFsQ==
17:18:35.194 -> [WS] [WS-Client] [sendHeader] Handshake:GET /socket.io/?EIO=4&transport=polling HTTP/1.1
17:18:35.194 -> Host: 44.201.229.255:5051
17:18:35.194 -> Connection: keep-alive
17:18:35.194 -> Authorization: 1234567890
17:18:35.194 -> User-Agent: arduino-WebSocket-Client
17:18:35.194 ->
17:18:35.194 ->
17:18:35.194 -> [WS] [write] n:168, t:26814
17:18:35.194 -> [WS] [write] Write, Length :168, Left :0
17:18:35.242 -> [WS] [WS-Client] [sendHeader] Sending header... Done (us):23341
17:18:35.569 -> [WS] [WS-Client][handleHeader] RX:HTTP/1.1 200 OK
17:18:36.086 -> [WS] [WS-Client][handleHeader] RX:Date: Thu, 15 Dec 2022 11:48:34 GMT
17:18:36.086 -> [WS] [WS-Client][handleHeader] RX:Server: WSGIServer/0.2 CPython/3.7.10
17:18:36.132 -> [WS] [WS-Client][handleHeader] RX:Content-Type: text/plain; charset=UTF-8
17:18:36.132 -> [WS] [WS-Client][handleHeader] RX:Access-Control-Allow-Credentials: true
17:18:36.132 -> [WS] [WS-Client][handleHeader] RX:Content-Length: 86
17:18:36.132 -> [WS] [WS-Client][handleHeader] Header read fin.
17:18:36.132 -> [WS] [WS-Client][handleHeader] Client settings:
17:18:36.132 -> [WS] [WS-Client][handleHeader] - cURL:/socket.io/?EIO=4
17:18:36.132 -> [WS] [WS-Client][handleHeader] - cKey:yuspF1pH/C5irr/l5UGFsQ==
17:18:36.132 -> [WS] [WS-Client][handleHeader] Server header:
17:18:36.132 -> [WS] [WS-Client][handleHeader] - cCode:200
17:18:36.179 -> [WS] [WS-Client][handleHeader] - cIsUpgrade:0
17:18:36.179 -> [WS] [WS-Client][handleHeader] - cIsWebsocket:1
17:18:36.179 -> [WS] [WS-Client][handleHeader] - cAccept:
17:18:36.179 -> [WS] [WS-Client][handleHeader] - cProtocol:arduino
17:18:36.179 -> [WS] [WS-Client][handleHeader] - cExtensions:
17:18:36.179 -> [WS] [WS-Client][handleHeader] - cVersion:0
17:18:36.179 -> [WS] [WS-Client][handleHeader] - cSessionId:
17:18:36.179 -> [WS] [WS-Client][handleHeader] Still missing cSessionId try Socket.IO
17:18:36.179 -> [WS] [WS-Client][handleHeader] socket.io json: 0{"sid":"azHx1MWe5rMwhn-AAAd","upgrades":[],"pingTimeout":20000,"pingInterval":25000}
17:18:36.225 -> [WS] [WS-Client][handleHeader] - cSessionId: azHx1MWe5rMwhn-AAAd
17:18:36.225 -> [WS] [WS-Client][handleHeader] Header read fin.
17:18:36.225 -> [WS] [WS-Client][handleHeader] Client settings:
17:18:36.225 -> [WS] [WS-Client][handleHeader] - cURL:/socket.io/?EIO=4
17:18:36.225 -> [WS] [WS-Client][handleHeader] - cKey:yuspF1pH/C5irr/l5UGFsQ==
17:18:36.225 -> [WS] [WS-Client][handleHeader] Server header:
17:18:36.225 -> [WS] [WS-Client][handleHeader] - cCode:200
17:18:36.225 -> [WS] [WS-Client][handleHeader] - cIsUpgrade:0
17:18:36.225 -> [WS] [WS-Client][handleHeader] - cIsWebsocket:1
17:18:36.225 -> [WS] [WS-Client][handleHeader] - cAccept:
17:18:36.273 -> [WS] [WS-Client][handleHeader] - cProtocol:arduino
17:18:36.273 -> [WS] [WS-Client][handleHeader] - cExtensions:
17:18:36.273 -> [WS] [WS-Client][handleHeader] - cVersion:0
17:18:36.273 -> [WS] [WS-Client][handleHeader] - cSessionId:azHx1MWe5rMwhn-AAAd
17:18:36.273 -> [WS] [WS-Client][handleHeader] found cSessionId
17:18:36.273 -> [WS] [WS-Client] [sendHeader] Sending header...
17:18:36.273 -> [WS] sendHeader: client->cKey = +G8SadSJBKLkzKviD0CAQQ==
17:18:36.273 -> [WS] [WS-Client] [sendHeader] Handshake:GET /socket.io/?EIO=4&transport=websocket&sid=azHx1MWe5rMwhn-AAAd HTTP/1.1
17:18:36.273 -> Host: 44.201.229.255:5051
17:18:36.273 -> Connection: Upgrade
17:18:36.273 -> Upgrade: websocket
17:18:36.319 -> Sec-WebSocket-Version: 13
17:18:36.319 -> Sec-WebSocket-Key: +G8SadSJBKLkzKviD0CAQQ==
17:18:36.319 -> Sec-WebSocket-Protocol: arduino
17:18:36.319 -> Authorization: 1234567890
17:18:36.319 -> User-Agent: arduino-WebSocket-Client
17:18:36.319 ->
17:18:36.319 ->
17:18:36.319 -> [WS] [write] n:317, t:27921
17:18:36.319 -> [WS] [write] Write, Length :317, Left :0
17:18:36.319 -> [WS] [WS-Client] [sendHeader] Sending header... Done (us):34319
17:18:36.693 -> [WS] [WS-Client][handleHeader] RX:HTTP/1.1 400 BAD REQUEST
17:18:37.347 -> [WS] [WS-Client][handleHeader] RX:Date: Thu, 15 Dec 2022 11:48:36 GMT
17:18:37.347 -> [WS] [WS-Client][handleHeader] RX:Server: WSGIServer/0.2 CPython/3.7.10
17:18:37.347 -> [WS] [WS-Client][handleHeader] RX:Content-Type: text/plain
17:18:37.347 -> [WS] [WS-Client][handleHeader] RX:Access-Control-Allow-Credentials: true
17:18:37.347 -> [WS] [WS-Client][handleHeader] RX:Content-Length: 13
17:18:37.347 -> [WS] [WS-Client][handleHeader] Header read fin.
17:18:37.347 -> [WS] [WS-Client][handleHeader] Client settings:
17:18:37.394 -> [WS] [WS-Client][handleHeader] - cURL:/socket.io/?EIO=4
17:18:37.394 -> [WS] [WS-Client][handleHeader] - cKey:+G8SadSJBKLkzKviD0CAQQ==
17:18:37.394 -> [WS] [WS-Client][handleHeader] Server header:
17:18:37.394 -> [WS] [WS-Client][handleHeader] - cCode:400
17:18:37.394 -> [WS] [WS-Client][handleHeader] - cIsUpgrade:0
17:18:37.394 -> [WS] [WS-Client][handleHeader] - cIsWebsocket:1
17:18:37.394 -> [WS] [WS-Client][handleHeader] - cAccept:
17:18:37.394 -> [WS] [WS-Client][handleHeader] - cProtocol:arduino
17:18:37.394 -> [WS] [WS-Client][handleHeader] - cExtensions:
17:18:37.394 -> [WS] [WS-Client][handleHeader] - cVersion:0
17:18:37.394 -> [WS] [WS-Client][handleHeader] - cSessionId:azHx1MWe5rMwhn_-AAAd
17:18:37.440 -> [WS] [WS-Client][handleHeader] found cSessionId
17:18:37.440 -> [WS] [WS-Client] [sendHeader] Sending header...
17:18:37.440 -> [WS] sendHeader: client->cKey = kgHFOFywa0PtFQcG0YHXhw==
17:18:37.440 -> [WS] [WS-Client] [sendHeader] Handshake:GET /socket.io/?EIO=4&transport=websocket&sid=azHx1MWe5rMwhn_-AAAd HTTP/1.1
17:18:37.440 -> Host: 44.201.229.255:5051
17:18:37.440 -> Connection: Upgrade
17:18:37.440 -> Upgrade: websocket
17:18:37.440 -> Sec-WebSocket-Version: 13
17:18:37.440 -> Sec-WebSocket-Key: kgHFOFywa0PtFQcG0YHXhw==
17:18:37.440 -> Sec-WebSocket-Protocol: arduino
17:18:37.440 -> Authorization: 1234567890
17:18:37.440 -> User-Agent: arduino-WebSocket-Client
17:18:37.487 ->
17:18:37.487 ->
17:18:37.487 -> [WS] [write] n:317, t:29072
17:18:37.487 -> [WS] [write] Write, Length :317, Left :0
17:18:37.487 -> [WS] [WS-Client] [sendHeader] Sending header... Done (us):44590
17:18:37.863 -> [WS] [WS-Client][handleHeader] RX:HTTP/1.1 400 BAD REQUEST
17:18:38.376 -> ["event_name",{"now":30001}]
17:18:39.920 -> [WS] [WS-Client][handleHeader] RX:Date: Thu, 15 Dec 2022 11:48:37 GMT
17:18:39.920 -> [WS] [WS-Client][handleHeader] RX:Server: WSGIServer/0.2 CPython/3.7.10
17:18:39.920 -> [WS] [WS-Client][handleHeader] RX:Content-Type: text/plain
17:18:39.967 -> [WS] [WS-Client][handleHeader] RX:Access-Control-Allow-Credentials: true
17:18:39.967 -> [WS] [WS-Client][handleHeader] RX:Content-Length: 13
17:18:39.967 -> [WS] [WS-Client][handleHeader] Header read fin.
17:18:39.967 -> [WS] [WS-Client][handleHeader] Client settings:
17:18:39.967 -> [WS] [WS-Client][handleHeader] - cURL:/socket.io/?EIO=4
17:18:39.967 -> [WS] [WS-Client][handleHeader] - cKey:kgHFOFywa0PtFQcG0YHXhw==
17:18:39.967 -> [WS] [WS-Client][handleHeader] Server header:
17:18:39.967 -> [WS] [WS-Client][handleHeader] - cCode:400
17:18:39.967 -> [WS] [WS-Client][handleHeader] - cIsUpgrade:0
17:18:39.967 -> [WS] [WS-Client][handleHeader] - cIsWebsocket:1
17:18:40.015 -> [WS] [WS-Client][handleHeader] - cAccept:
17:18:40.015 -> [WS] [WS-Client][handleHeader] - cProtocol:arduino
17:18:40.015 -> [WS] [WS-Client][handleHeader] - cExtensions:
17:18:40.015 -> [WS] [WS-Client][handleHeader] - cVersion:0
17:18:40.015 -> [WS] [WS-Client][handleHeader] - cSessionId:azHx1MWe5rMwhn_-AAAd
17:18:40.015 -> [WS] [WS-Client][handleHeader] found cSessionId
17:18:40.015 -> [WS] [WS-Client] [sendHeader] Sending header...
17:18:40.015 -> [WS] sendHeader: client->cKey = EecIQfKzvQuNNyVjzVGKIw==
17:18:40.015 -> [WS] [WS-Client] [sendHeader] Handshake:GET /socket.io/?EIO=4&transport=websocket&sid=azHx1MWe5rMwhn_-AAAd HTTP/1.1
17:18:40.015 -> Host: 44.201.229.255:5051
17:18:40.060 -> Connection: Upgrade
17:18:40.060 -> Upgrade: websocket
17:18:40.060 -> Sec-WebSocket-Version: 13
17:18:40.060 -> Sec-WebSocket-Key: EecIQfKzvQuNNyVjzVGKIw==
17:18:40.060 -> Sec-WebSocket-Protocol: arduino
17:18:40.060 -> Authorization: 1234567890
17:18:40.060 -> User-Agent: arduino-WebSocket-Client
17:18:40.060 ->

It would be very helpful if you could help me to resolve this problem. thank you

Run websocket only mode for Socket.IO

Is there a way to run "websocket" only mode with Socket.IO on this Arduino library ?

I made a local Socket.IO client that works well with the WebSockets_Generic Example "WiFiNINA-->WebSocketClientSocketIO_NINA" - but only if the server has "transport=["polling", "websocket"]," defined.

If I change the server to "transport=["websocket"]," then it does not work anymore.

However, our application absolutely requires "websocket only" configuration !

On other Socket.IO clients there is a possibility to force to "websocket only".
For example in the iOS-client there is a config setting called ".forceWebsockets(true)," that makes exactly that.

The keyword, I think, is called "websocket only". Please refer to the Socket.IO documentation here and the error you get if websocket only is missing is explained here

Is there a "websocket only" mode for the WebSockets_Generic library ?
If yes, how would I configure it ?

Support as Http server and the Websockets server on Arduino DUE

Hello,
Sorry i want so talk about Websockets Server Examples.

i am want wo work with the library with Arduino DUE and PlatformIO last version from Today.
My projectis based on AJAX now i want to switch some functions to Websockets.
I have an working Webserver with html files on SDCard, and i want to bring these Library as websock server on the DUE. Normal Ethernet shiled with the WizNet 5100 controller and SDslot.

Is this posible ?
The PC ist only the client and the DUE is the Server for http and Websock paralel.
The Due sends the data to the Client Browser on the pc.

I havent seen an Examble as Server also not found realy the DUE as suppotert, well only the list for the toolchain.

tanks
Jake

WebSocketsClient still reconnects after calling .disconnect()

Describe the bug

Can't find any info in the docs. So asking here:
There is .setReconnectInterval() method for specifying a reconnection interval. And there is a .disconnect() method.

I was assuming that automatic reconnection happens only on network errors. And if the client explicitly calls .disconnect() - no reconnections should occur after that. But for now, the client is still reconnecting.

Is this an expected behaviour? Or it is a bug? And how to disconnect?

multiple definition of `WebSocketsClient::*`

Describe the bug

Hi there! First of all, thnx for your library!

I'm implementing another library that relies on this one. So to be able to use objects and methods from this library I had exactly one include of this library in my main header file.
Something like this in mylibrary.h

#include <WebSocketsClient_Generic.h>

I also have a mylibrary.cpp with again has exactly one include of its header:

#include "mylibrary.h"

Now I'm making an arduino sketch (ino) where I include only my library header. Something like this:

#include <mylibrary.h>

I'm trying to compile the sketch and am getting a bunch of errors about multiple definitions:

/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::messageReceived(WSclient_t*, WSopcode_t, unsigned char*, unsigned int, bool)':
/Users/kostik/Library/Arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/1.22.0-97-gc752ad5-5.2.0/xtensa-esp32-elf/include/c++/5.2.0/bits/stl_tree.h:2223: multiple definition of `WebSocketsClient::messageReceived(WSclient_t*, WSopcode_t, unsigned char*, unsigned int, bool)'
/sketch/mylibrary-Test.ino.cpp.o:/Users/kostik/Projects/Arduino/libraries/WebSockets_Generic/src/WebSocketsClient_Generic-Impl.h:806: first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSockets::write(WSclient_t*, unsigned char*, unsigned int)':
mylibrary.cpp:(.text._ZN10WebSockets5writeEP10WSclient_tPhj+0x0): multiple definition of `WebSockets::write(WSclient_t*, unsigned char*, unsigned int)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN10WebSockets5writeEP10WSclient_tPhj+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::clientDisconnect(WSclient_t*)':
mylibrary.cpp:(.text._ZN16WebSocketsClient16clientDisconnectEP10WSclient_t+0x0): multiple definition of `WebSocketsClient::clientDisconnect(WSclient_t*)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient16clientDisconnectEP10WSclient_t+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::clientIsConnected(WSclient_t*)':
mylibrary.cpp:(.text._ZN16WebSocketsClient17clientIsConnectedEP10WSclient_t+0x0): multiple definition of `WebSocketsClient::clientIsConnected(WSclient_t*)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient17clientIsConnectedEP10WSclient_t+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WS_IPAddressToString(IPAddress const&)':
mylibrary.cpp:(.text._Z20WS_IPAddressToStringRK9IPAddress+0x0): multiple definition of `WS_IPAddressToString(IPAddress const&)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._Z20WS_IPAddressToStringRK9IPAddress+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSockets::createHeader(unsigned char*, WSopcode_t, unsigned int, bool, unsigned char*, bool)':
mylibrary.cpp:(.text._ZN10WebSockets12createHeaderEPh10WSopcode_tjbS0_b+0x0): multiple definition of `WebSockets::createHeader(unsigned char*, WSopcode_t, unsigned int, bool, unsigned char*, bool)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN10WebSockets12createHeaderEPh10WSopcode_tjbS0_b+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSockets::sendFrameHeader(WSclient_t*, WSopcode_t, unsigned int, bool)':
mylibrary.cpp:(.text._ZN10WebSockets15sendFrameHeaderEP10WSclient_t10WSopcode_tjb+0x0): multiple definition of `WebSockets::sendFrameHeader(WSclient_t*, WSopcode_t, unsigned int, bool)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN10WebSockets15sendFrameHeaderEP10WSclient_t10WSopcode_tjb+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSockets::sendFrame(WSclient_t*, WSopcode_t, unsigned char*, unsigned int, bool, bool)':
mylibrary.cpp:(.text._ZN10WebSockets9sendFrameEP10WSclient_t10WSopcode_tPhjbb+0x0): multiple definition of `WebSockets::sendFrame(WSclient_t*, WSopcode_t, unsigned char*, unsigned int, bool, bool)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN10WebSockets9sendFrameEP10WSclient_t10WSopcode_tPhjbb+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSockets::clientDisconnect(WSclient_t*, unsigned short, char*, unsigned int)':
mylibrary.cpp:(.text._ZN10WebSockets16clientDisconnectEP10WSclient_ttPcj+0x0): multiple definition of `WebSockets::clientDisconnect(WSclient_t*, unsigned short, char*, unsigned int)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN10WebSockets16clientDisconnectEP10WSclient_ttPcj+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSockets::handleWebsocketPayloadCb(WSclient_t*, bool, unsigned char*)':
mylibrary.cpp:(.text._ZN10WebSockets24handleWebsocketPayloadCbEP10WSclient_tbPh+0x0): multiple definition of `WebSockets::handleWebsocketPayloadCb(WSclient_t*, bool, unsigned char*)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN10WebSockets24handleWebsocketPayloadCbEP10WSclient_tbPh+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSockets::headerDone(WSclient_t*)':
mylibrary.cpp:(.text._ZN10WebSockets10headerDoneEP10WSclient_t+0x0): multiple definition of `WebSockets::headerDone(WSclient_t*)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN10WebSockets10headerDoneEP10WSclient_t+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSockets::base64_encode(unsigned char*, unsigned int)':
mylibrary.cpp:(.text._ZN10WebSockets13base64_encodeEPhj+0x0): multiple definition of `WebSockets::base64_encode(unsigned char*, unsigned int)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN10WebSockets13base64_encodeEPhj+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSockets::acceptKey(String&)':
mylibrary.cpp:(.text._ZN10WebSockets9acceptKeyER6String+0x0): multiple definition of `WebSockets::acceptKey(String&)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN10WebSockets9acceptKeyER6String+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSockets::write(WSclient_t*, char const*)':
mylibrary.cpp:(.text._ZN10WebSockets5writeEP10WSclient_tPKc+0x0): multiple definition of `WebSockets::write(WSclient_t*, char const*)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN10WebSockets5writeEP10WSclient_tPKc+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSockets::enableHeartbeat(WSclient_t*, unsigned int const&, unsigned int const&, unsigned char const&)':
mylibrary.cpp:(.text._ZN10WebSockets15enableHeartbeatEP10WSclient_tRKjS3_RKh+0x0): multiple definition of `WebSockets::enableHeartbeat(WSclient_t*, unsigned int const&, unsigned int const&, unsigned char const&)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN10WebSockets15enableHeartbeatEP10WSclient_tRKjS3_RKh+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSockets::handleHBTimeout(WSclient_t*)':
mylibrary.cpp:(.text._ZN10WebSockets15handleHBTimeoutEP10WSclient_t+0x0): multiple definition of `WebSockets::handleHBTimeout(WSclient_t*)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN10WebSockets15handleHBTimeoutEP10WSclient_t+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::WebSocketsClient()':
mylibrary.cpp:(.text._ZN16WebSocketsClientC2Ev+0x0): multiple definition of `WebSocketsClient::WebSocketsClient()'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClientC2Ev+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::WebSocketsClient()':
mylibrary.cpp:(.text._ZN16WebSocketsClientC2Ev+0x0): multiple definition of `WebSocketsClient::WebSocketsClient()'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClientC2Ev+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::begin(char const*, unsigned short const&, char const*, char const*)':
mylibrary.cpp:(.text._ZN16WebSocketsClient5beginEPKcRKtS1_S1_+0x0): multiple definition of `WebSocketsClient::begin(char const*, unsigned short const&, char const*, char const*)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient5beginEPKcRKtS1_S1_+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::begin(String const&, unsigned short const&, String const&, String const&)':
mylibrary.cpp:(.text._ZN16WebSocketsClient5beginERK6StringRKtS2_S2_+0x0): multiple definition of `WebSocketsClient::begin(String const&, unsigned short const&, String const&, String const&)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient5beginERK6StringRKtS2_S2_+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::begin(IPAddress const&, unsigned short const&, char const*, char const*)':
mylibrary.cpp:(.text._ZN16WebSocketsClient5beginERK9IPAddressRKtPKcS6_+0x0): multiple definition of `WebSocketsClient::begin(IPAddress const&, unsigned short const&, char const*, char const*)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient5beginERK9IPAddressRKtPKcS6_+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::begin(IPAddress const&, unsigned short const&, String const&, String const&)':
mylibrary.cpp:(.text._ZN16WebSocketsClient5beginERK9IPAddressRKtRK6StringS7_+0x0): multiple definition of `WebSocketsClient::begin(IPAddress const&, unsigned short const&, String const&, String const&)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient5beginERK9IPAddressRKtRK6StringS7_+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::beginSSL(char const*, unsigned short const&, char const*, char const*, char const*)':
mylibrary.cpp:(.text._ZN16WebSocketsClient8beginSSLEPKcRKtS1_S1_S1_+0x0): multiple definition of `WebSocketsClient::beginSSL(char const*, unsigned short const&, char const*, char const*, char const*)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient8beginSSLEPKcRKtS1_S1_S1_+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::beginSSL(String const&, unsigned short const&, String const&, String const&, String const&)':
mylibrary.cpp:(.text._ZN16WebSocketsClient8beginSSLERK6StringRKtS2_S2_S2_+0x0): multiple definition of `WebSocketsClient::beginSSL(String const&, unsigned short const&, String const&, String const&, String const&)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient8beginSSLERK6StringRKtS2_S2_S2_+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::beginSSL(IPAddress const&, unsigned short const&, String const&, String const&, String const&)':
mylibrary.cpp:(.text._ZN16WebSocketsClient8beginSSLERK9IPAddressRKtRK6StringS7_S7_+0x0): multiple definition of `WebSocketsClient::beginSSL(IPAddress const&, unsigned short const&, String const&, String const&, String const&)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient8beginSSLERK9IPAddressRKtRK6StringS7_S7_+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::beginSslWithCA(char const*, unsigned short const&, char const*, char const*, char const*)':
mylibrary.cpp:(.text._ZN16WebSocketsClient14beginSslWithCAEPKcRKtS1_S1_S1_+0x0): multiple definition of `WebSocketsClient::beginSslWithCA(char const*, unsigned short const&, char const*, char const*, char const*)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient14beginSslWithCAEPKcRKtS1_S1_S1_+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::beginSocketIO(char const*, unsigned short const&, char const*, char const*)':
mylibrary.cpp:(.text._ZN16WebSocketsClient13beginSocketIOEPKcRKtS1_S1_+0x0): multiple definition of `WebSocketsClient::beginSocketIO(char const*, unsigned short const&, char const*, char const*)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient13beginSocketIOEPKcRKtS1_S1_+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::beginSocketIO(String const&, unsigned short const&, String const&, String const&)':
mylibrary.cpp:(.text._ZN16WebSocketsClient13beginSocketIOERK6StringRKtS2_S2_+0x0): multiple definition of `WebSocketsClient::beginSocketIO(String const&, unsigned short const&, String const&, String const&)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient13beginSocketIOERK6StringRKtS2_S2_+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::beginSocketIO(IPAddress const&, unsigned short const&, String const&, String const&)':
mylibrary.cpp:(.text._ZN16WebSocketsClient13beginSocketIOERK9IPAddressRKtRK6StringS7_+0x0): multiple definition of `WebSocketsClient::beginSocketIO(IPAddress const&, unsigned short const&, String const&, String const&)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient13beginSocketIOERK9IPAddressRKtRK6StringS7_+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::beginSocketIOSSL(char const*, unsigned short const&, char const*, char const*)':
mylibrary.cpp:(.text._ZN16WebSocketsClient16beginSocketIOSSLEPKcRKtS1_S1_+0x0): multiple definition of `WebSocketsClient::beginSocketIOSSL(char const*, unsigned short const&, char const*, char const*)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient16beginSocketIOSSLEPKcRKtS1_S1_+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::beginSocketIOSSL(String const&, unsigned short const&, String const&, String const&)':
mylibrary.cpp:(.text._ZN16WebSocketsClient16beginSocketIOSSLERK6StringRKtS2_S2_+0x0): multiple definition of `WebSocketsClient::beginSocketIOSSL(String const&, unsigned short const&, String const&, String const&)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient16beginSocketIOSSLERK6StringRKtS2_S2_+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::beginSocketIOSSL(IPAddress const&, unsigned short const&, String const&, String const&)':
mylibrary.cpp:(.text._ZN16WebSocketsClient16beginSocketIOSSLERK9IPAddressRKtRK6StringS7_+0x0): multiple definition of `WebSocketsClient::beginSocketIOSSL(IPAddress const&, unsigned short const&, String const&, String const&)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient16beginSocketIOSSLERK9IPAddressRKtRK6StringS7_+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::beginSocketIOSSLWithCA(char const*, unsigned short const&, char const*, char const*, char const*)':
mylibrary.cpp:(.text._ZN16WebSocketsClient22beginSocketIOSSLWithCAEPKcRKtS1_S1_S1_+0x0): multiple definition of `WebSocketsClient::beginSocketIOSSLWithCA(char const*, unsigned short const&, char const*, char const*, char const*)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient22beginSocketIOSSLWithCAEPKcRKtS1_S1_S1_+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::sendTXT(unsigned char*, unsigned int, bool)':
mylibrary.cpp:(.text._ZN16WebSocketsClient7sendTXTEPhjb+0x0): multiple definition of `WebSocketsClient::sendTXT(unsigned char*, unsigned int, bool)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient7sendTXTEPhjb+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::sendTXT(char*, unsigned int, bool)':
mylibrary.cpp:(.text._ZN16WebSocketsClient7sendTXTEPcjb+0x0): multiple definition of `WebSocketsClient::sendTXT(char*, unsigned int, bool)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient7sendTXTEPcjb+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::sendTXT(char const*, unsigned int)':
mylibrary.cpp:(.text._ZN16WebSocketsClient7sendTXTEPKcj+0x0): multiple definition of `WebSocketsClient::sendTXT(char const*, unsigned int)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient7sendTXTEPKcj+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::sendTXT(unsigned char const*, unsigned int)':
mylibrary.cpp:(.text._ZN16WebSocketsClient7sendTXTEPKhj+0x0): multiple definition of `WebSocketsClient::sendTXT(unsigned char const*, unsigned int)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient7sendTXTEPKhj+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::sendTXT(String const&)':
mylibrary.cpp:(.text._ZN16WebSocketsClient7sendTXTERK6String+0x0): multiple definition of `WebSocketsClient::sendTXT(String const&)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient7sendTXTERK6String+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::sendTXT(char)':
mylibrary.cpp:(.text._ZN16WebSocketsClient7sendTXTEc+0x0): multiple definition of `WebSocketsClient::sendTXT(char)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient7sendTXTEc+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::sendBIN(unsigned char*, unsigned int, bool)':
mylibrary.cpp:(.text._ZN16WebSocketsClient7sendBINEPhjb+0x0): multiple definition of `WebSocketsClient::sendBIN(unsigned char*, unsigned int, bool)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient7sendBINEPhjb+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::sendBIN(unsigned char const*, unsigned int)':
mylibrary.cpp:(.text._ZN16WebSocketsClient7sendBINEPKhj+0x0): multiple definition of `WebSocketsClient::sendBIN(unsigned char const*, unsigned int)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient7sendBINEPKhj+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::sendPing(unsigned char*, unsigned int)':
mylibrary.cpp:(.text._ZN16WebSocketsClient8sendPingEPhj+0x0): multiple definition of `WebSocketsClient::sendPing(unsigned char*, unsigned int)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient8sendPingEPhj+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::sendPing(String const&)':
mylibrary.cpp:(.text._ZN16WebSocketsClient8sendPingERK6String+0x0): multiple definition of `WebSocketsClient::sendPing(String const&)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient8sendPingERK6String+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::disconnect()':
mylibrary.cpp:(.text._ZN16WebSocketsClient10disconnectEv+0x0): multiple definition of `WebSocketsClient::disconnect()'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient10disconnectEv+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::~WebSocketsClient()':
mylibrary.cpp:(.text._ZN16WebSocketsClientD2Ev+0x0): multiple definition of `WebSocketsClient::~WebSocketsClient()'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClientD2Ev+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::~WebSocketsClient()':
mylibrary.cpp:(.text._ZN16WebSocketsClientD2Ev+0x0): multiple definition of `WebSocketsClient::~WebSocketsClient()'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClientD2Ev+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::~WebSocketsClient()':
mylibrary.cpp:(.text._ZN16WebSocketsClientD0Ev+0x0): multiple definition of `WebSocketsClient::~WebSocketsClient()'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClientD0Ev+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::setAuthorization(char const*, char const*)':
mylibrary.cpp:(.text._ZN16WebSocketsClient16setAuthorizationEPKcS1_+0x0): multiple definition of `WebSocketsClient::setAuthorization(char const*, char const*)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient16setAuthorizationEPKcS1_+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::setAuthorization(char const*)':
mylibrary.cpp:(.text._ZN16WebSocketsClient16setAuthorizationEPKc+0x0): multiple definition of `WebSocketsClient::setAuthorization(char const*)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient16setAuthorizationEPKc+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::setExtraHeaders(char const*)':
mylibrary.cpp:(.text._ZN16WebSocketsClient15setExtraHeadersEPKc+0x0): multiple definition of `WebSocketsClient::setExtraHeaders(char const*)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient15setExtraHeadersEPKc+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::setReconnectInterval(unsigned long const&)':
mylibrary.cpp:(.text._ZN16WebSocketsClient20setReconnectIntervalERKm+0x0): multiple definition of `WebSocketsClient::setReconnectInterval(unsigned long const&)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient20setReconnectIntervalERKm+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::isConnected()':
mylibrary.cpp:(.text._ZN16WebSocketsClient11isConnectedEv+0x0): multiple definition of `WebSocketsClient::isConnected()'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient11isConnectedEv+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::sendHeader(WSclient_t*)':
mylibrary.cpp:(.text._ZN16WebSocketsClient10sendHeaderEP10WSclient_t+0x0): multiple definition of `WebSocketsClient::sendHeader(WSclient_t*)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient10sendHeaderEP10WSclient_t+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::handleHeader(WSclient_t*, String*)':
mylibrary.cpp:(.text._ZN16WebSocketsClient12handleHeaderEP10WSclient_tP6String+0x0): multiple definition of `WebSocketsClient::handleHeader(WSclient_t*, String*)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient12handleHeaderEP10WSclient_tP6String+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::connectedCb()':
mylibrary.cpp:(.text._ZN16WebSocketsClient11connectedCbEv+0x0): multiple definition of `WebSocketsClient::connectedCb()'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient11connectedCbEv+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::connectFailedCb()':
mylibrary.cpp:(.text._ZN16WebSocketsClient15connectFailedCbEv+0x0): multiple definition of `WebSocketsClient::connectFailedCb()'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient15connectFailedCbEv+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::handleHBPing()':
mylibrary.cpp:(.text._ZN16WebSocketsClient12handleHBPingEv+0x0): multiple definition of `WebSocketsClient::handleHBPing()'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient12handleHBPingEv+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::enableHeartbeat(unsigned int const&, unsigned int const&, unsigned char const&)':
mylibrary.cpp:(.text._ZN16WebSocketsClient15enableHeartbeatERKjS1_RKh+0x0): multiple definition of `WebSocketsClient::enableHeartbeat(unsigned int const&, unsigned int const&, unsigned char const&)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient15enableHeartbeatERKjS1_RKh+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::disableHeartbeat()':
mylibrary.cpp:(.text._ZN16WebSocketsClient16disableHeartbeatEv+0x0): multiple definition of `WebSocketsClient::disableHeartbeat()'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient16disableHeartbeatEv+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSockets::readCb(WSclient_t*, unsigned char*, unsigned int, std::function<void (WSclient_t*, bool)>)':
mylibrary.cpp:(.text._ZN10WebSockets6readCbEP10WSclient_tPhjSt8functionIFvS1_bEE+0x0): multiple definition of `WebSockets::readCb(WSclient_t*, unsigned char*, unsigned int, std::function<void (WSclient_t*, bool)>)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN10WebSockets6readCbEP10WSclient_tPhjSt8functionIFvS1_bEE+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSockets::handleWebsocketWaitFor(WSclient_t*, unsigned int)':
mylibrary.cpp:(.text._ZN10WebSockets22handleWebsocketWaitForEP10WSclient_tj+0x0): multiple definition of `WebSockets::handleWebsocketWaitFor(WSclient_t*, unsigned int)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN10WebSockets22handleWebsocketWaitForEP10WSclient_tj+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSockets::handleWebsocketCb(WSclient_t*)':
mylibrary.cpp:(.text._ZN10WebSockets17handleWebsocketCbEP10WSclient_t+0x0): multiple definition of `WebSockets::handleWebsocketCb(WSclient_t*)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN10WebSockets17handleWebsocketCbEP10WSclient_t+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSockets::handleWebsocket(WSclient_t*)':
mylibrary.cpp:(.text._ZN10WebSockets15handleWebsocketEP10WSclient_t+0x0): multiple definition of `WebSockets::handleWebsocket(WSclient_t*)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN10WebSockets15handleWebsocketEP10WSclient_t+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::handleClientData()':
mylibrary.cpp:(.text._ZN16WebSocketsClient16handleClientDataEv+0x0): multiple definition of `WebSocketsClient::handleClientData()'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient16handleClientDataEv+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::loop()':
mylibrary.cpp:(.text._ZN16WebSocketsClient4loopEv+0x0): multiple definition of `WebSocketsClient::loop()'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient4loopEv+0x0): first defined here
/libraries/mylibrary/mylibrary.cpp.o: In function `WebSocketsClient::onEvent(std::function<void (WStype_t, unsigned char*, unsigned int)>)':
mylibrary.cpp:(.text._ZN16WebSocketsClient7onEventESt8functionIFv8WStype_tPhjEE+0x0): multiple definition of `WebSocketsClient::onEvent(std::function<void (WStype_t, unsigned char*, unsigned int)>)'
/sketch/mylibrary-Test.ino.cpp.o:mylibrary-Test.ino.cpp:(.text._ZN16WebSocketsClient7onEventESt8functionIFv8WStype_tPhjEE+0x0): first defined here
collect2: error: ld returned 1 exit status

Actually compilation succeeds, but the linking stage — not :(

I am using ESP32 DOIT ESP32DEVKIT V1 board but i suppose that doesn't matter.
Test examples of the library works as expected.

So why is it happening? Am i doing something wrong? Can you advice?
Thnx!

Ethernet with SSL

I am trying to connect to a Socket.IO server with Ethernet and SSL.

The Board: MKR WiFi1010
The Ethernet Shield: MKR ETH stacked on top of the MKR WiFi1010

I was thinking of using the EthernetWebServer_SSL library.

EthernetClient client;
EthernetSSLClient sslClient(client, TAs, (size_t)TAs_NUM);

However, I do not see a way on how to achieve the connection with the SocketIO client.

SocketIOclient socketIO;

Obviously, in my code there is no SSL connection yet. And therefore the connection does not work as can be seen in the following log:

Connected! My IP address: 192.168.1.65
Connecting to WebSockets Server @ IP address: test.test.com, port: 443
[WS] WebSockets_Generic v2.11.1
[WS] [wsIOc] found EIO=4 disable EIO ping on client
[WS] [WS-Client] Connect wss...
Receiving Payload:

[IOc] Disconnected
[WS] [wsIOc] Disconnected!

Below is my entire code. The SSL-certifcate is placed in the trust_anchors.h file as described in the EthernetWebServer_SSL library.

Questions:

  1. How do I link the sslClient to the socketIO client correctly ? Or is this the wrong way at all ?

  2. How would I achieve SSL and Ethernet with the WebSocket_Generic's Socket.IO library ?

  3. Is the call to socketIO.beginSSL(server, serverPort); automatically doing SSL ? Or is there something missing ? How do I achieve SSL with Socket.IO ?

Thanks.

#include <EthernetWebServer_SSL.h>
#include "trust_anchors.h"  // You must have Trihow SSL Certificates here
#include "arduino_secrets.h"
#include <ArduinoJson.h>
#include <Adafruit_NeoPixel.h> 
#include <Ramp.h>

#define BOARD_NAME "ARDUINO_SAMD_MKRWIFI1010"
#define USE_THIS_SS_PIN 5     // MKR ETH shield

#define _WEBSOCKETS_LOGLEVEL_     3
#define WEBSOCKETS_NETWORK_TYPE   NETWORK_WIFININA

// For transport=websocket instead of transport=polling
#define USING_STICKY_SESSION_SIO        false

#include <ArduinoJson.h>

#include <WebSocketsClient_Generic.h>
#include <SocketIOclient_Generic.h>

SocketIOclient socketIO;

byte mac[] = { 0xA8, 0x61, 0x0A, 0xAE, 0x28, 0x9C };    // MAC Adress of Arduino MKR ETH Shield
uint16_t serverPort = SOCKET_IO_PORT; // from arduino_secrets.h
char server[] = SOCKET_IO_SERVER_URL; // from arduino_secrets.h

EthernetClient client;
EthernetSSLClient sslClient(client, TAs, (size_t)TAs_NUM);

unsigned long messageTimestamp = 0;

void socketIOEvent(socketIOmessageType_t type, uint8_t* payload, size_t length) {
    
  Serial.println("Receiving Payload:") ;
  Serial.println((char*)payload);
  
  switch (type) {
    case sIOtype_DISCONNECT:
      Serial.println("[IOc] Disconnected");
      break;
    case sIOtype_CONNECT:
      Serial.print("[IOc] Connected to url: ");
      Serial.println((char*)payload);

      // join default namespace (no auto join in Socket.IO V3)
      socketIO.send(sIOtype_CONNECT, "/");

      break;
    case sIOtype_EVENT:
      Serial.print("[IOc] Get event: ");
      Serial.println((char*)payload);

      break;
    case sIOtype_ACK:
      Serial.print("[IOc] Get ack: ");
      Serial.println(length);

      //hexdump(payload, length);
      break;
    case sIOtype_ERROR:
      Serial.print("[IOc] Get error: ");
      Serial.println(length);

      //hexdump(payload, length);
      break;
    case sIOtype_BINARY_EVENT:
      Serial.print("[IOc] Get binary: ");
      Serial.println(length);

      //hexdump(payload, length);
      break;
    case sIOtype_BINARY_ACK:
      Serial.print("[IOc] Get binary ack: ");
      Serial.println(length);

      //hexdump(payload, length);
      break;

    default:
      Serial.println("[IOc] Default case...");
      break;
  }
}

void setup() {  
  
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  delay(2000);

  Ethernet.init(USE_THIS_SS_PIN);

  Ethernet.begin(mac);

  Serial.print(F("Connected! My IP address: "));
  Serial.println(Ethernet.localIP());

  // give the Ethernet shield a second to initialize:
  delay(2000);

  // server address, port and URL
  Serial.print("Connecting to WebSockets Server @ IP address: ");
  Serial.print(server);
  Serial.print(", port: ");
  Serial.println(serverPort);

  // setReconnectInterval to 10s, new from v2.5.1 to avoid flooding server. Default is 0.5s
  socketIO.setReconnectInterval(10000);

  socketIO.setExtraHeaders(SOCKET_IO_AUTHORIZATION);  // from arduino_secrets.h

  socketIO.beginSSL(server, serverPort);

  socketIO.onEvent(socketIOEvent);
}

void loop() {

    socketIO.loop();

    uint64_t now = millis();
    
    if (now - messageTimestamp > 30000) {
    
        messageTimestamp = now;
        
        // create JSON message for Socket.IO (event)
        DynamicJsonDocument doc(1024);
        JsonArray array = doc.to<JsonArray>();
        
        // add event name    // Hint: socket.on('event_name', ....
        array.add("subscribe");
        
        // add payload (parameters) for the event
        JsonObject param = array.createNestedObject();
        
        param["userName"] = "Default Test";
        param["sessionId"] = "th-VIZsyFibjFj1xGLPL4fk";
        
        // JSON to String (serializion)
        String output;
        output += "0";  // same as Web
        serializeJson(doc, output);
        
        // Send event
        socketIO.sendEVENT(output); 
        
        // Print JSON for debugging
        Serial.println(output);
    }
}

Network/Power failure

Describe the bug

When the client suddenly dies/disconnects due to network/power failure in WebSockets_Generic. Since the client wont have any chance to emit a disconnect event to the server

Arduino IDE version: 1.8.19
Wemos-D1
OS: MacOs
Server: NodeJs exporess + SocketIO


Steps to reproduce:
1. use esp8266 example
2. upload code to borad
3. connect to server success
4. power off the broad

Generic_WebSocketServer_LEDcontrol_W5500 run error

/examples/Generic/W5500/Generic_WebSocketServer_LEDcontrol_W5500
run error:
WebSocketBadStatusException: Handshake status 400 Bad Request
websocket._exceptions.WebSocketBadStatusException: Handshake status 400 Bad Request

Hardware : teensy3.6,ws5500,
arduino version: 1.8.12
browser: google chrome 83.0.4103.106 64.

Error compiling for board Seeeduino Wio Terminal.

Describe the bug

BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" fails to identify installed board.

Steps to Reproduce

Install seedstudio SAMD boards using the board manager https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json

open the example WIOTerminal_WebSocketClient.ino available from Websocket_Generic for WIO_Terminal

compile sketch

Expected behavior

example code should be able to compile and run on designated board.

Actual behavior

Code fails when uploading to board

Debug and AT-command log (if applicable)

C:\Users\gbernal\AppData\Local\Temp\arduino_modified_sketch_974006\WIOTerminal_WebSocketClient.ino:21:2: warning: #warning Using SEEED_WIO_TERMINAL [-Wcpp]

 #warning Using SEEED_WIO_TERMINAL

  ^~~~~~~

In file included from C:\Users\gbernal\Documents\Arduino\libraries\Seeed_Arduino_rpcUnified\src/lwip/arch.h:49:0,

                 from C:\Users\gbernal\Documents\Arduino\libraries\Seeed_Arduino_rpcUnified\src/lwip/debug.h:40,

                 from C:\Users\gbernal\Documents\Arduino\libraries\Seeed_Arduino_rpcUnified\src/lwip/opt.h:52,

                 from C:\Users\gbernal\Documents\Arduino\libraries\Seeed_Arduino_rpcUnified\src/lwip/ip_addr.h:40,

                 from C:\Users\gbernal\Documents\Arduino\libraries\Seeed_Arduino_rpcUnified\src/esp/tcpip_adapter.h:44,

                 from C:\Users\gbernal\Documents\Arduino\libraries\Seeed_Arduino_rpcUnified\src/esp/esp_event.h:25,

                 from C:\Users\gbernal\Documents\Arduino\libraries\Seeed_Arduino_rpcUnified\src/esp/esp_event_loop.h:22,

                 from C:\Users\gbernal\Documents\Arduino\libraries\Seeed_Arduino_rpcUnified\src/esp/esp_lib_unified.h:12,

                 from C:\Users\gbernal\Documents\Arduino\libraries\Seeed_Arduino_rpcUnified\src/seeed_rpcUnified.h:11,

                 from C:\Users\gbernal\Documents\Arduino\libraries\Seeed_Arduino_rpcWiFi\src/WiFiGeneric.h:26,

                 from C:\Users\gbernal\Documents\Arduino\libraries\Seeed_Arduino_rpcWiFi\src/WiFiSTA.h:28,

                 from C:\Users\gbernal\Documents\Arduino\libraries\Seeed_Arduino_rpcWiFi\src/WiFi.h:32,

                 from C:\Users\gbernal\Documents\Arduino\libraries\Seeed_Arduino_rpcWiFi\src/rpcWiFi.h:1,

                 from C:\Users\gbernal\AppData\Local\Temp\arduino_modified_sketch_974006\WIOTerminal_WebSocketClient.ino:33:

C:\Users\gbernal\Documents\Arduino\libraries\Seeed_Arduino_rpcUnified\src/lwip/arch/cc.h:44:0: warning: "BYTE_ORDER" redefined

 #define BYTE_ORDER LITTLE_ENDIAN

 

In file included from c:\users\gbernal\appdata\local\arduino15\packages\seeeduino\tools\arm-none-eabi-gcc\7-2017q4\arm-none-eabi\include\sys\types.h:67:0,

                 from c:\users\gbernal\appdata\local\arduino15\packages\seeeduino\tools\arm-none-eabi-gcc\7-2017q4\arm-none-eabi\include\stdio.h:61,

                 from C:\Users\gbernal\AppData\Local\Arduino15\packages\Seeeduino\hardware\samd\1.8.2\cores\arduino/Print.h:23,

                 from C:\Users\gbernal\AppData\Local\Arduino15\packages\Seeeduino\hardware\samd\1.8.2\cores\arduino/Stream.h:26,

                 from C:\Users\gbernal\AppData\Local\Arduino15\packages\Seeeduino\hardware\samd\1.8.2\cores\arduino/HardwareSerial.h:24,

                 from C:\Users\gbernal\AppData\Local\Arduino15\packages\Seeeduino\hardware\samd\1.8.2\cores\arduino/Arduino.h:83,

                 from C:\Users\gbernal\AppData\Local\Temp\arduino_build_912138\sketch\WIOTerminal_WebSocketClient.ino.cpp:1:

c:\users\gbernal\appdata\local\arduino15\packages\seeeduino\tools\arm-none-eabi-gcc\7-2017q4\arm-none-eabi\include\machine\endian.h:20:0: note: this is the location of the previous definition

 #define BYTE_ORDER _BYTE_ORDER

 

In file included from C:\Users\gbernal\Documents\Arduino\libraries\WebSockets_Generic\src/WebSockets_Generic.h:101:0,

                 from C:\Users\gbernal\Documents\Arduino\libraries\WebSockets_Generic\src/WebSocketsClient_Generic.h:67,

                 from C:\Users\gbernal\AppData\Local\Temp\arduino_modified_sketch_974006\WIOTerminal_WebSocketClient.ino:37:

C:\Users\gbernal\Documents\Arduino\libraries\WebSockets_Generic\src/WebSocketsVersion_Generic.h:70:0: warning: "WEBSOCKETS_GENERIC_VERSION_MINOR" redefined

 #define WEBSOCKETS_GENERIC_VERSION_MINOR    10

 

In file included from C:\Users\gbernal\Documents\Arduino\libraries\WebSockets_Generic\src/WebSocketsClient_Generic.h:67:0,

                 from C:\Users\gbernal\AppData\Local\Temp\arduino_modified_sketch_974006\WIOTerminal_WebSocketClient.ino:37:

C:\Users\gbernal\Documents\Arduino\libraries\WebSockets_Generic\src/WebSockets_Generic.h:70:0: note: this is the location of the previous definition

 #define WEBSOCKETS_GENERIC_VERSION_MINOR      13

 

In file included from C:\Users\gbernal\Documents\Arduino\libraries\WebSockets_Generic\src/WebSockets_Generic.h:101:0,

                 from C:\Users\gbernal\Documents\Arduino\libraries\WebSockets_Generic\src/WebSocketsClient_Generic.h:67,

                 from C:\Users\gbernal\AppData\Local\Temp\arduino_modified_sketch_974006\WIOTerminal_WebSocketClient.ino:37:

C:\Users\gbernal\Documents\Arduino\libraries\WebSockets_Generic\src/WebSocketsVersion_Generic.h:71:0: warning: "WEBSOCKETS_GENERIC_VERSION_PATCH" redefined

 #define WEBSOCKETS_GENERIC_VERSION_PATCH    1

 

In file included from C:\Users\gbernal\Documents\Arduino\libraries\WebSockets_Generic\src/WebSocketsClient_Generic.h:67:0,

                 from C:\Users\gbernal\AppData\Local\Temp\arduino_modified_sketch_974006\WIOTerminal_WebSocketClient.ino:37:

C:\Users\gbernal\Documents\Arduino\libraries\WebSockets_Generic\src/WebSockets_Generic.h:71:0: note: this is the location of the previous definition

 #define WEBSOCKETS_GENERIC_VERSION_PATCH      0

 

In file included from C:\Users\gbernal\Documents\Arduino\libraries\WebSockets_Generic\src/WebSockets_Generic.h:101:0,

                 from C:\Users\gbernal\Documents\Arduino\libraries\WebSockets_Generic\src/WebSocketsClient_Generic.h:67,

                 from C:\Users\gbernal\AppData\Local\Temp\arduino_modified_sketch_974006\WIOTerminal_WebSocketClient.ino:37:

C:\Users\gbernal\Documents\Arduino\libraries\WebSockets_Generic\src/WebSocketsVersion_Generic.h:73:0: warning: "WEBSOCKETS_GENERIC_VERSION_INT" redefined

 #define WEBSOCKETS_GENERIC_VERSION_INT      2010001

 

In file included from C:\Users\gbernal\Documents\Arduino\libraries\WebSockets_Generic\src/WebSocketsClient_Generic.h:67:0,

                 from C:\Users\gbernal\AppData\Local\Temp\arduino_modified_sketch_974006\WIOTerminal_WebSocketClient.ino:37:

C:\Users\gbernal\Documents\Arduino\libraries\WebSockets_Generic\src/WebSockets_Generic.h:73:0: note: this is the location of the previous definition

 #define WEBSOCKETS_GENERIC_VERSION_INT        2013000

 

In file included from C:\Users\gbernal\Documents\Arduino\libraries\WebSockets_Generic\src/WebSocketsClient_Generic.h:67:0,

                 from C:\Users\gbernal\AppData\Local\Temp\arduino_modified_sketch_974006\WIOTerminal_WebSocketClient.ino:37:

C:\Users\gbernal\Documents\Arduino\libraries\WebSockets_Generic\src/WebSockets_Generic.h:210:4: warning: #warning Use SAMD21/SAMD51 in WebSockets_Generic [-Wcpp]

   #warning Use SAMD21/SAMD51 in WebSockets_Generic

    ^~~~~~~

In file included from C:\Users\gbernal\Documents\Arduino\libraries\WebSockets_Generic\src/WebSocketsClient_Generic.h:67:0,

                 from C:\Users\gbernal\AppData\Local\Temp\arduino_modified_sketch_974006\WIOTerminal_WebSocketClient.ino:37:

C:\Users\gbernal\Documents\Arduino\libraries\WebSockets_Generic\src/WebSockets_Generic.h:559:4: warning: #warning Using RTL8720DN Seeed_Arduino_rpcWiFi Library [-Wcpp]

   #warning Using RTL8720DN Seeed_Arduino_rpcWiFi Library

    ^~~~~~~

C:\Users\gbernal\Documents\Arduino\libraries\WebSockets_Generic\src/WebSockets_Generic.h:636:4: warning: #warning This network type Supporting SSL for WebSockets [-Wcpp]

   #warning This network type Supporting SSL for WebSockets

    ^~~~~~~

In file included from C:\Users\gbernal\Documents\Arduino\libraries\WebSockets_Generic\src/WebSockets_Generic.h:816:0,

                 from C:\Users\gbernal\Documents\Arduino\libraries\WebSockets_Generic\src/WebSocketsClient_Generic.h:67,

                 from C:\Users\gbernal\AppData\Local\Temp\arduino_modified_sketch_974006\WIOTerminal_WebSocketClient.ino:37:

C:\Users\gbernal\Documents\Arduino\libraries\WebSockets_Generic\src/WebSockets_Generic-Impl.h:82:6: warning: #warning CORE_HAS_LIBB64 [-Wcpp]

     #warning CORE_HAS_LIBB64

      ^~~~~~~

In file included from C:\Users\gbernal\Documents\Arduino\libraries\WebSockets_Generic\src/WebSocketsClient_Generic.h:247:0,

                 from C:\Users\gbernal\AppData\Local\Temp\arduino_modified_sketch_974006\WIOTerminal_WebSocketClient.ino:37:

C:\Users\gbernal\Documents\Arduino\libraries\WebSockets_Generic\src/WebSocketsClient_Generic-Impl.h:320:4: warning: #warning WEBSOCKETS_NETWORK_TYPE != NETWORK_ESP8266_ASYNC [-Wcpp]

   #warning WEBSOCKETS_NETWORK_TYPE != NETWORK_ESP8266_ASYNC

    ^~~~~~~

C:\Users\gbernal\Documents\Arduino\libraries\WebSockets_Generic\src/WebSocketsClient_Generic-Impl.h:342:4: warning: #warning HAS_SSL [-Wcpp]

   #warning HAS_SSL

    ^~~~~~~

C:\Users\gbernal\Documents\Arduino\libraries\WebSockets_Generic\src/WebSocketsClient_Generic-Impl.h:363:4: warning: #warning ESP32 or NETWORK_RTL8720DN [-Wcpp]

   #warning ESP32 or NETWORK_RTL8720DN

    ^~~~~~~

C:\Users\gbernal\Documents\Arduino\libraries\WebSockets_Generic\src/WebSocketsClient_Generic-Impl.h: In member function 'void WebSocketsClient::loop()':

C:\Users\gbernal\Documents\Arduino\libraries\WebSockets_Generic\src/WebSocketsClient_Generic-Impl.h:400:22: error: 'class WiFiClientSecure' has no member named 'setInsecure'

         _client.ssl->setInsecure();

                      ^~~~~~~~~~~

exit status 1
Error compiling for board Seeeduino Wio Terminal.

Screenshots

image

Information

Please ensure to specify the following:

  • Arduino IDE version 1.8.11
  • `Seeeduino Wio Terminal.
  • test example code
  • Simplest possible steps to reproduce

OS - Windows 10

Example

Arduino IDE version: 1.8.13
ESP32 Core Version 1.0.5
OS: Ubuntu 20.04 LTS
Linux xy-Inspiron-3593 5.4.0-66-generic #74-Ubuntu SMP Wed Jan 27 22:54:38 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Context:
I encountered an endless loop while trying to connect to Local WiFi.

Steps to reproduce:


Install seedstudio SAMD boards using the board manager https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json

open the example WIOTerminal_WebSocketClient.ino available from Websocket_Generic for WIO_Terminal
 
compile sketch
### Additional context

Add any other context about the problem here.

Ping events propagated to main code socketIO events

Is your feature request related to a problem? Please describe.

Using SocketIO with your library, I could really use the "ping"/"pong" events in the main code to detect when I am off internet.

One application of this feature-request is to trigger my watchdog timer in my Arduino board. If, for some reason, the internet is off then the Arduino board would get restarted.

Describe the solution you'd like

In order to make the above feature work, all we have to add is the following:
(of course not knowing if you have an even better solution to this - if you do, please let me know....)

Inside SocketIOclient_Generic.h file, you can add an event enum (see last line case 7):

typedef enum
{
  sIOtype_CONNECT      = '0',
  sIOtype_DISCONNECT   = '1',
  sIOtype_EVENT        = '2',
  sIOtype_ACK          = '3',
  sIOtype_ERROR        = '4',
  sIOtype_BINARY_EVENT = '5',
  sIOtype_BINARY_ACK   = '6',
  sIOtype_PING         = '7',
} socketIOmessageType_t;

And inside SocketIOclient_Generic-Impl.h file, you can add one line of code to "deviate" the ping to the events-listener in the main code (please not the extra line with runIOCbEvent(sIOtype_PING, payload, length);)

case eIOtype_PING:
  payload[0] = eIOtype_PONG;
  
  WSK_LOGWARN1("[wsIOc] get ping send pong:", (char *) payload);
  
  WebSocketsClient::sendTXT(payload, length, false);            
  runIOCbEvent(sIOtype_PING, payload, length);
  
  break;

This allows in the main code:

void socketIOEvent(socketIOmessageType_t type, uint8_t* payload, size_t length) {
  
    // switch socketIO events
    switch (type) {

        case sIOtype_PING:
            /* PING */
            watchdog.kick();

            break;
    // ...
    }
}

Additional context
I tried to make a pull-request with this but the appropriate permissions are not available.

Feel free to implement the above solution if you find it helpful for others. Thank you.

Arduino Portenta not connect to SocketIO example

Arduino Portenta not connect to SocketIO example

I'm trying to connect a Arduino Portenta as SocketIO client to the SocketIO server example in this repo and it keeps disconnecting. After a few tries a check if the problem was the portenta or the library so I ran the same example with a ESP-32 and a ESP-8266 and both works but when I try with Portenta keep Disconnecting and it's weird becuase in the Server logs never shows a connection but with ESP32 or ESP8266 shows each time that a client is Connected.

Steps to Reproduce

Information

  • Arduino IDE Version: 2.0.0-rc6
  • Arduino Portenta
  • Arduino mbed OS portenta boards V3.0.1

Example

Start WebSocketClientSocketIO_WiFi on PORTENTA_H7_M7WebSockets_Generic v2.15.0
Connecting to SSID: Lastra
SSID: Lastra
WebSockets Client IP Address: 192.168.0.107
signal strength (RSSI):-62 dBm
Connecting to WebSockets Server @ IP address: 192.168.0.5, port: 8080
[WS] [WS-Client] beginSocketIO with IPAddress
[WS] [WS-Client] beginSocketIO with const char
[WS] WebSockets_Generic v2.15.0
[WS] [wsIOc] found EIO=4 disable EIO ping on client
[WS] [WS-Client] connectedCb
[WS] [WS-Client][connectedCb] Connected to Host:192.168.0.5, Port:8080
[WS] [WS-Client] [sendHeader] Sending header...
[WS] sendHeader: client->cKey = mrl30JBiab+xRJYPbSZE6A==
[WS] [WS-Client] [sendHeader] Handshake:GET /socket.io/?EIO=4&transport=polling HTTP/1.1
Host: 192.168.0.5:8080
Connection: keep-alive
Authorization: 1234567890
User-Agent: arduino-WebSocket-Client


[WS] [write] n:165, t:20558
[WS] [write] Write, Length :165, Left :0
[WS] [WS-Client] [sendHeader] Sending header... Done (us):1110
[WS] [WS-Client][handleHeader] RX:HTTP/1.1 200 OK
[WS] [WS-Client][handleHeader] RX:Content-Type: text/plain; charset=UTF-8
[WS] [WS-Client][handleHeader] RX:Content-Length: 118
[WS] [WS-Client][handleHeader] RX:Date: Fri, 13 May 2022 19:16:21 GMT
[WS] [WS-Client][handleHeader] RX:Connection: keep-alive
[WS] [WS-Client][handleHeader] Header read fin.
[WS] [WS-Client][handleHeader] Client settings:
[WS] [WS-Client][handleHeader] - cURL:/socket.io/?EIO=4
[WS] [WS-Client][handleHeader] - cKey:mrl30JBiab+xRJYPbSZE6A==
[WS] [WS-Client][handleHeader] Server header:

[WS] [WS-Client][handleHeader] - cCode:200
[WS] [WS-Client][handleHeader] - cIsUpgrade:0
[WS] [WS-Client][handleHeader] - cIsWebsocket:1
[WS] [WS-Client][handleHeader] - cAccept:
[WS] [WS-Client][handleHeader] - cProtocol:arduino
[WS] [WS-Client][handleHeader] - cExtensions:
[WS] [WS-Client][handleHeader] - cVersion:0
[WS] [WS-Client][handleHeader] - cSessionId:
[WS] [WS-Client][handleHeader] Still missing cSessionId try Socket.IO
[WS] [WS-Client][handleHeader] socket.io json: 0{"sid":"uHxZNe6cfsiJuPMGAAAL","upgrades":["websocket"],"pingInterval":25000,"pingTimeout":20000,"maxPayload":1000
[WS] [WS-Client][handleHeader] - cSessionId: uHxZNe6cfsiJuPMGAAAL
[WS] [WS-Client][handleHeader] Header read fin.
[WS] [WS-Client][handleHeader] Client settings:
[WS] [WS-Client][handleHeader] - cURL:/socket.io/?EIO=4
[WS] [WS-Client][handleHeader] - cKey:mrl30JBiab+xRJYPbSZE6A==
[WS] [WS-Client][handleHeader] Server header:
[WS] [WS-Client][handleHeader] - cCode:200
[WS] [WS-Client][handleHeader] - cIsUpgrade:0
[WS] [WS-Client][handleHeader] - cIsWebsocket:1
[WS] [WS-Client][handleHeader] - cAccept:
[WS] [WS-Client][handleHeader] - cProtocol:arduino
[WS] [WS-Client][handleHeader] - cExtensions:
[WS] [WS-Client][handleHeader] - cVersion:0
[WS] [WS-Client][handleHeader] - cSessionId:uHxZNe6cfsiJuPMGAAAL
[WS] [WS-Client][handleHeader] found cSessionId
[WS] [WS-Client] [sendHeader] Sending header...
[WS] sendHeader: client->cKey = DTT5PkIBNTgxX3MUKD/XYg==
[WS] [WS-Client] [sendHeader] Handshake:GET /socket.io/?EIO=4&transport=websocket&sid=uHxZNe6cfsiJuPMGAAAL HTTP/1.1
Host: 192.168.0.5:8080
Connection: Upgrade
Upgrade: websocket
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: DTT5PkIBNTgxX3MUKD/XYg==
Sec-WebSocket-Protocol: arduino
Authorization: 1234567890
User-Agent: arduino-WebSocket-Client


[WS] [write] n:314, t:20585
[WS] [write] Write, Length :314, Left :0
[WS] [WS-Client] [sendHeader] Sending header... Done (us):1368
[WS] [WS-Client][handleHeader] RX:000}HTTP/1.1 101 Switching Protocols
[WS] [WS-Client][handleHeader] Header error:000}HTTP/1.1 101 Switching Protocols
[WS] [WS-Client][handleHeader] RX:Upgrade: websocket
[WS] [WS-Client][handleClientData] Header response timeout.. Disconnecting!
[WS] [WS-Client] client disconnected.
[IOc] Disconnected
[WS] [wsIOc] Disconnected!
["event_name",{"now":30001}]
[WS] [WS-Client] connectedCb
[WS] [WS-Client][connectedCb] Connected to Host:192.168.0.5, Port:8080
[WS] [WS-Client] [sendHeader] Sending header...
[WS] sendHeader: client->cKey = ZqaYvn9TscOSf2OKSewQmg==
[WS] [WS-Client] [sendHeader] Handshake:GET /socket.io/?EIO=4&transport=polling HTTP/1.1
Host: 192.168.0.5:8080
Connection: keep-alive
Authorization: 1234567890
User-Agent: arduino-WebSocket-Client

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.