Git Product home page Git Product logo

khoih-prog / websockets2_generic Goto Github PK

View Code? Open in Web Editor NEW
80.0 8.0 29.0 4.33 MB

A WebSocket Server and Client library for Arduino, based on RFC6455, for writing modern Websockets applications. Now support ESP8266, ESP32 (including ESP32-S2 Saola, AI-Thinker ESP-12K, WT32_ETH01, etc.), nRF52, SAMD21, SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, Teensy, RP2040-based, etc. boards, with WiFiNINA, Teensy 4.1 NativeEthernet/QNEthernet, Ethernet W5x00 / ENC28J60 / LAN8742A / LAN8720, ESP8266 / ESP32-AT modules/shields, as well as SINRIC / Alexa / Google Home

License: GNU General Public License v3.0

C++ 72.74% C 27.04% Shell 0.22%
ethernet nrf52840 w5x00 lan8742a esp32 esp8266 stm32 teensy wifinina websocket-server

websockets2_generic's Issues

Portenta WiFi Websockets tested lately?

Hi @khoih-prog any idea if anyone has lately tested the PortentaH7 with this library. I can't seem to get websocket type chat working.

I do use a web based websocket server, but that shouldn't be the issue. If I use 2 Portenta's is there an easily way to test if they are working?

I am using this example folder

https://github.com/khoih-prog/WebSockets2_Generic/tree/master/examples/Generic/Portenta_H7/WiFi

I really just want an SSL websocket client, but should I just be able to test one Portenta as a client and one as the server?

Actually that seems fairly simple. I will test that out.

......

Ok I tested the Portenta server and client. Looked fairly easy to understand. But no connection


Connected to Wifi, IP address: 192.168.137.36
Connecting to WebSockets Server @192.168.137.128
[WS] WebsocketsClient::connect: not _connectionOpen, host = 192.168.137.128 , port = 8080
Not Connected!

Any idea why?

send token in header.

I have problem can anyone help me? how to connect web socket server, while connecting I need to send token (already generated JSON token) in header.

Endless loop reading line from client

Teensy41_NativeEthernet_tcp.hpp, line 103:

WSString readLine() override
{
  WSString line = "";

  int ch = -1;

  while ( ch != '\n' && available())
  {
    // It is important to call `client.available()`. Otherwise no data can be read.
    if (client.available())
    {
      ch = client.read();

      if (ch >= 0)
      {
        line += (char) ch;
      }
    }
  }

  return line;
}

sometimes client.available() return false, but available() still true then the loop is endless

Secured-Esp32-Client Example not works on NodeMcu32s (Esp32s)

Secured-Esp32-Client Example on esp32 shows not connected. I am also tried different working wss links and none of them working.
1
I am using arduino 15 IDE, WebSockets2_Generic v1.1.0
checked access point internet connection.
Serial monitor logs

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1216
ho 0 tail 12 room 4
load:0x40078000,len:10944
load:0x40080400,len:6388
entry 0x400806b4

Starting WebSockets Secured-ESP32-Client on ESP32_DEV
WebSockets2_Generic v1.1.0
.....Connected to Wifi, Connecting to WebSockets Server @wss://echo.websocket.org/
[WS] WebsocketsClient::doestStartsWith: str = wss://echo.websocket.org/
[WS] WebsocketsClient::doestStartsWith: prefix = http://
[WS] WebsocketsClient::doestStartsWith: str = wss://echo.websocket.org/
[WS] WebsocketsClient::doestStartsWith: prefix = ws://
[WS] WebsocketsClient::doestStartsWith: str = wss://echo.websocket.org/
[WS] WebsocketsClient::doestStartsWith: prefix = wss://
Not Connected!

Running Http and Websocket Servers concurrently

@jakespeed1311

This is an issue from WebSockets_Generic Library relating to this WebSockets2_Generic Library

Support as Http server and the webscok server on Arduino DUE

Moving it now to the correct place

Probably it works because your clients are constantly querying the websocket and can do that ?

If you specify your problem early, it'll be helpful and save time

OK, if I understand correctly now, your problem is that

  1. the WebSocketServer is in blocking mode
  2. you don't have any WebSockets Client
  3. WS Server is blocked, waiting for Client before moving forward
  4. The HTTP WebServer can't continue.

If so, I think I can fix the problem by modifying the WebSockets2_Generic Library.

Please wait until I find out the fix and post the new release.

I'm moving the issue to the correct place of WebSockets2_Generic Library.

Is it compatible with MRK GSM 1400?

Arduino MKR GSM 1400
SAMD core version 1.8.9
Arduino IDE 1.8.13
MacOS 10.13.6

I was wondering whether I could connect through WebSocket with this library and the MRK GSM 1400 board?

I built the project and ran it with a dummy configuration but I couldn't pass step 1 when it tries to connect.

Output:
01:40:17.153 -> Starting SAMD-Ethernet-Minimal-Client on SAMD MKRGSM1400
01:40:17.153 -> Ethernet using W5x00 and Ethernet Library
01:40:17.153 -> WebSockets2_Generic v1.1.0
01:40:17.153 -> [WS] WebsocketsClient::connect: step 1

Thanks!

what is websocketclient if no incoming request?

after

client = SocketsServer.accept();

after no incoming client connection request,

is it a single client object? only one client allowed at a time?

how can I push messages to the client asynchronously?

I would build an array of clients from accept
and loop thru each for incoming messages,
but send based on other events, data status change, elasped time....

[Questions] How to receive binary data?

Questions 1
Example is ESP32_WebSocketClient.ino
How to receive binary data?

Questions 2
Sometimes the connection with the server is lost.
When the connection to the server is lost

client.connect(websockets server_host, websockets server_port, "/");

doesn't connect, is there any other way?

thank you

WebSockets2_Generic example problem

In example : https://github.com/khoih-prog/WebSockets2_Generic/tree/master/examples/Generic/Ethernet/ESP32/ESP32_Ethernet_ServerAllFunctionsDemo

I have problem with varialble: wsServer - this varialbe not define in browser
I create two server.on
server.on("/", - problem with varialble: wsServer (orange,red)
server.on("/test" - (blue) here I replace text "new WebSocket(wsServer, ['arduino']); "
by my ipadress "new WebSocket("ws://192.168.1.10:8080/", ['arduino']);"
-result see in attachment

A testing on
WebSockets2_Generic 1.12.0 and 1.12.1 latest same result
VS CODE -platformIO :
espressif/toolchain-xtensa-esp32s2@ 8.4.0+2021r2-patch3
framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.5

webSocket

CA Certificate not getting verified ?

Describe the bug

The WebSocket Client doesn't seem to verify the CA Certificate even when one is provided through "client.setCACert(ssl_ca_cert)" method.

Steps to Reproduce

  1. Enter Correct Certificate to the Sketch (Or just use the git provided example).
  2. Change a few letters of the certificate.
  3. Try to connect, and the client will connect to the server.

PS: client.setInsecure() method had NOT been used;

Expected behavior

Client should not connect to the Server.

Actual behavior

Client connects to the Server.

Information

Please ensure to specify the following:

  • PIO Version : Core : 5.2.4, Home 3.4.0
  • ESP32 - Wrover

*PLATFORM: Espressif 32 (3.4.0) > Espressif ESP32-DEVKITC-VE (WROVER) CUSTOM
*PACKAGES:

    • framework-arduinoespressif32 0.0.0+sha.fdec056
    • framework-espidf 3.40001.200521 (4.0.1)

Uploading and running example of ESP "Minimal-Esp32-Client" error [ 4159][E][WiFiClient.cpp:313] setSocketOption(): fail on -1, errno: 9, "Bad file number"

Describe the bug

I tried to run the example of ESP32 called "Minimal-Esp32-Client" (and other examples, but this one is the easiest to reproduce), then the monitor printed

[ 4159][E][WiFiClient.cpp:313] setSocketOption(): fail on -1, errno: 9, "Bad file number"

and then
Not Connected!

Steps to Reproduce

I am using visual studio code with PlatformIO and created a new project of ESP32 on Arduino framework.
Just put the example code "Minimal-Esp32-Client" with your wifi ssid and password and the websocket server to connect to and it will do it

PlatformIO version: Core 6.1.4 - Home 3.4.3
Core Version: I am not sure, i think Arduino-mbed
Board type: ESP32
Contextual information: I tried to run the example code
Using Windows 10

Screenshot 2022-10-19 234205

Serious problem with timeout when sending packages

Hi,

We've developed a solution using the Pico 2040W that gets data from an Acconner radar chip (core 1) and saves this into a circular buffer that is then read and uploaded (core 0) using this library. We're using the WifiMulti library to connect and manage our wireless network connection, and I've done extensive testing to make sure that library functions as intended โ€“ it does.

Our main concern is that the thread (core 0) responsible for offloading the radar frames, sent as binary data, randomly freezes when the connection is bad or when the connection to the websocket is lost. Sometimes this seems to happen without an actual closed event being fired, and the available() method also returns a status indicating that the connection is alive and well, despite the connection obviously not working.

Since our application is led to believe that the connection is still working, we proceed with trying to send data โ€“ and this process seems to have a very long timeout, hanging our core on each and every send for approximately 5 seconds, before returning true, indicating that a send was indeed successful, despite that not being the case.

So there seems to be multiple problems:

  1. The first one being that the library doesn't detect if the connection actually drops and available() keeps saying that the connection is fine.
  2. The send method found here is still called, despite the connecting not being available, and the _client send method seems to have a timeout of about 5000 ms.
  3. The third and final issue also has to do with line linked above. That the send method assumes that the transfer went through, which is just not a good idea for a TCP transfer, and means that our application is fooled yet again.

Are there any prospects for solutions on these issues? If not I think that we'll unfortunately have to move to a plain TCP socket based solution as the embedded code is dependent on issues like this not happening.

Thank you! :)

RobotDyn SamD21 M0 Zero compatible board

I was testing the example in https://github.com/khoih-prog/WebSockets2_Generic/tree/master/examples/Generic/Ethernet/SAMD/SAMD-Ethernet_AdvancedWebServer
but got nothing in the serial output.

These clone boards (https://www.aliexpress.com/item/32780674095.html?spm=a2g0s.9042311.0.0.27424c4dcsNo3b) are called Zero compatible, but don't have 2 USB ports like a real Zero (serial programming and serial USB).
The only port they have is the serial USB

So I had to add following code in the sketch example:

#if PLATFORM_ARCH == PLATFORM_ARCHITECTURE_SAMD21
#  define _SERIAL SerialUSB
#else
#  define _SERIAL Serial
#endif

and to use everywhere
_SERIAL.println

QNEthernet higher latency

First, many thanks for an awesome library!

I would like to report a bug and a possible solution but not sure if this introduces any other issues but this seems to have improved the problem for me..

Describe the bug

When using QNEthernet on a teensy 4.1 websocket server, there seems to be 5-6x latency compared to Native ethernet when sending data
using client.send

Reading https://github.com/ssilverman/QNEthernet#write-immediacy

It seems that the client.write waits for a timeout or enough data to send that adds about 150ms delay for each call

This change in Teensy41_QNEthernet_tcp.hpp seems to correct the problem

void send(const WSString& data) override
{
 client.write(reinterpret_cast<uint8_t*>(const_cast<char*>(data.c_str())), data.size());
 **client.flush();** 
}

void send(const WSString&& data) override
{
 client.write(reinterpret_cast<uint8_t*>(const_cast<char*>(data.c_str())), data.size());
 **client.flush();**
}

void send(const uint8_t* data, const uint32_t len) override
{
 client.write(data, len);
 **client.flush();**
}

BW
Marios

Compile error with Arduino Nano RP2040

Arduino:1.8.15 Hourly Build 2021/05/19 12:35 (Mac OS X 10.14.6), Board : "Arduino Nano RP2040 Connect"
mbed_nano/2.4.1

I've try to compile the simple WebSocket Client example with the changes:

#if ( defined(ARDUINO_ARDUINO_NANO33BLE) || defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_MBED_RP2040) || defined(ARDUINO_ARCH_RP2040) )
#define WEBSOCKETS_USE_WIFININA           true
#else
#error This code is intended to run only on the RP2040 boards ! Please check your Tools->Board setting.
#endif

#if defined(WEBSOCKETS_WIFININA_USE_NRF52)

#if defined(ARDUINO_ARDUINO_NANO33BLE)
#define BOARD_TYPE      "ARDUINO_ARDUINO_NANO33BLE"
#elif defined(ARDUINO_ARCH_SAMD)
#define BOARD_TYPE      "ARDUINO_ARCH_SAMD"
#elif defined(ARDUINO_ARCH_MBED_RP2040)
#define BOARD_TYPE      "ARDUINO_ARCH_MBED_RP2040"
#elif defined(ARDUINO_ARCH_RP2040)
#define BOARD_TYPE      "ARDUINO_ARCH_RP2040"
#else
#define BOARD_TYPE      "RP2040 Unknown"
#endif

#endif

And get this compile error:

Arduino:1.8.15 Hourly Build 2021/05/19 12:35 (Mac OS X), Carte : "Arduino Nano RP2040 Connect"

In file included from /Users/bobby/Documents/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic.h:53:0,
                 from /Users/bobby/Documents/Arduino/RP2040-Client-Websocket2_Generic/RP2040-Client-Websocket2_Generic.ino:34:
/Users/bobby/Documents/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/server.hpp:96:51: error: expected ')' before '*' token
       WebsocketsServer(network2_generic::TcpServer* server = new WSDefaultTcpServer);
                                                   ^
/Users/bobby/Documents/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/server.hpp:112:25: error: 'TcpServer' in namespace 'websockets2_generic::network2_generic' does not name a type
       network2_generic::TcpServer* _server;
                         ^~~~~~~~~
In file included from /Users/bobby/Documents/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic.h:56:0,
                 from /Users/bobby/Documents/Arduino/RP2040-Client-Websocket2_Generic/RP2040-Client-Websocket2_Generic.ino:34:
/Users/bobby/Documents/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp: In constructor 'websockets2_generic::WebsocketsClient::WebsocketsClient()':
/Users/bobby/Documents/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:56:76: error: 'WSDefaultTcpClient' was not declared in this scope
   WebsocketsClient::WebsocketsClient() : WebsocketsClient(std::make_shared<WSDefaultTcpClient>())
                                                                            ^~~~~~~~~~~~~~~~~~
/Users/bobby/Documents/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:56:96: error: no matching function for call to 'make_shared<<expression error> >()'
   WebsocketsClient::WebsocketsClient() : WebsocketsClient(std::make_shared<WSDefaultTcpClient>())
                                                                                                ^
In file included from /Users/bobby/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/c++/7.2.1/memory:81:0,
                 from /Users/bobby/Library/Arduino15/packages/arduino/hardware/mbed_nano/2.4.1/cores/arduino/mbed/platform/cxxsupport/mstd_memory:34,
                 from /Users/bobby/Library/Arduino15/packages/arduino/hardware/mbed_nano/2.4.1/cores/arduino/mbed/platform/cxxsupport/mstd_functional:31,
                 from /Users/bobby/Library/Arduino15/packages/arduino/hardware/mbed_nano/2.4.1/cores/arduino/mbed/platform/include/platform/Callback.h:27,
                 from /Users/bobby/Library/Arduino15/packages/arduino/hardware/mbed_nano/2.4.1/cores/arduino/mbed/platform/include/platform/FileHandle.h:23,
                 from /Users/bobby/Library/Arduino15/packages/arduino/hardware/mbed_nano/2.4.1/cores/arduino/macros.h:41,
                 from /Users/bobby/Library/Arduino15/packages/arduino/hardware/mbed_nano/2.4.1/variants/NANO_RP2040_CONNECT/pins_arduino.h:2,
                 from /Users/bobby/Library/Arduino15/packages/arduino/hardware/mbed_nano/2.4.1/cores/arduino/Arduino.h:76,
                 from sketch/RP2040-Client-Websocket2_Generic.ino.cpp:1:
/Users/bobby/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/c++/7.2.1/bits/shared_ptr.h:703:5: note: candidate: template<class _Tp, class ... _Args> std::shared_ptr<_Tp> std::make_shared(_Args&& ...)
     make_shared(_Args&&... __args)
     ^~~~~~~~~~~
/Users/bobby/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/c++/7.2.1/bits/shared_ptr.h:703:5: note:   template argument deduction/substitution failed:
In file included from /Users/bobby/Documents/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic.h:56:0,
                 from /Users/bobby/Documents/Arduino/RP2040-Client-Websocket2_Generic/RP2040-Client-Websocket2_Generic.ino:34:
/Users/bobby/Documents/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:56:96: error: template argument 1 is invalid
   WebsocketsClient::WebsocketsClient() : WebsocketsClient(std::make_shared<WSDefaultTcpClient>())
                                                                                                ^
In file included from /Users/bobby/Documents/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic.h:56:0,
                 from /Users/bobby/Documents/Arduino/RP2040-Client-Websocket2_Generic/RP2040-Client-Websocket2_Generic.ino:34:
/Users/bobby/Documents/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp: In member function 'void websockets2_generic::WebsocketsClient::upgradeToSecuredConnection()':
/Users/bobby/Documents/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:400:23: error: 'WSDefaultSecuredTcpClient' does not name a type
     auto client = new WSDefaultSecuredTcpClient;
                       ^~~~~~~~~~~~~~~~~~~~~~~~~
/Users/bobby/Documents/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:466:37: error: 'WSDefaultSecuredTcpClient' was not declared in this scope
     this->_client = std::shared_ptr<WSDefaultSecuredTcpClient>(client);
                                     ^~~~~~~~~~~~~~~~~~~~~~~~~
/Users/bobby/Documents/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:466:62: error: template argument 1 is invalid
     this->_client = std::shared_ptr<WSDefaultSecuredTcpClient>(client);
                                                              ^
In file included from /Users/bobby/Documents/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic.h:57:0,
                 from /Users/bobby/Documents/Arduino/RP2040-Client-Websocket2_Generic/RP2040-Client-Websocket2_Generic.ino:34:
/Users/bobby/Documents/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Server.hpp: At global scope:
/Users/bobby/Documents/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Server.hpp:54:37: error: expected constructor, destructor, or type conversion before '(' token
   WebsocketsServer::WebsocketsServer(network2_generic::TcpServer* server) : _server(server) {}
                                     ^
/Users/bobby/Documents/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Server.hpp: In member function 'bool websockets2_generic::WebsocketsServer::available()':
/Users/bobby/Documents/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Server.hpp:58:18: error: 'class websockets2_generic::WebsocketsServer' has no member named '_server'
     return this->_server->available();
                  ^~~~~~~
/Users/bobby/Documents/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Server.hpp: In member function 'void websockets2_generic::WebsocketsServer::listen(uint16_t)':
/Users/bobby/Documents/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Server.hpp:63:11: error: 'class websockets2_generic::WebsocketsServer' has no member named '_server'
     this->_server->listen(port);
           ^~~~~~~
/Users/bobby/Documents/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Server.hpp: In member function 'bool websockets2_generic::WebsocketsServer::poll()':
/Users/bobby/Documents/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Server.hpp:68:18: error: 'class websockets2_generic::WebsocketsServer' has no member named '_server'
     return this->_server->poll();
                  ^~~~~~~
/Users/bobby/Documents/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Server.hpp: In member function 'websockets2_generic::WebsocketsClient websockets2_generic::WebsocketsServer::accept()':
/Users/bobby/Documents/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Server.hpp:125:60: error: '_server' was not declared in this scope
     std::shared_ptr<network2_generic::TcpClient> tcpClient(_server->accept());
                                                            ^~~~~~~
/Users/bobby/Documents/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Server.hpp: In destructor 'virtual websockets2_generic::WebsocketsServer::~WebsocketsServer()':
/Users/bobby/Documents/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Server.hpp:195:11: error: 'class websockets2_generic::WebsocketsServer' has no member named '_server'
     this->_server->close();
           ^~~~~~~
exit status 1

Ethernet and wifi in the same board

Hi

I'm using the arduino mkr wifi 1010 with the ethernet shield (W5500) because, in case of no wifi available, ethernet must be the alternative for connect to the server. I wanted to use your library for communicate using both solutions but it seem is not possible. To be more precise the problem is all the library code is all inside the .hpp header (why?) and is not possible to include the same header in two different .cpp (one configured for wifi and other for ethernet). Including in both source files generate a linker error caused by the conflict of the double function body compiled in the same project. Do you know if exist a workaround for have both devices wifi and ethernet working in the same firmware?
Thank you

Enhancement:

Hello,

Unfortunately I can contribute less code than I would like to, but thanks again for the great work.

The new unblocking function was successfully tested, thanks!
But unfortunately it reads the websocket connection immediately after sending the echo.
This is unfortunately exactly the problem.
Actually, it's just the server that outputs the data until the web socket is closed by the client.

What would I like to achieve.

  1. the client connects to the webserver and presses a html butt, we say "Enable Logging".
  2. a new page is called and from the webserver and in it is a javascript that opens the websocket to the server.
  3. the browser now sends its request to the server via the websocket... which in turn replies with a string example current time
    (actually I want to display the debug output of a traffic " DCC ". )
  4. from now on the browser (javascript) waits for data from the server to output it as http.
  5. the server outputs the current time/DCC data via the socket
  6. enough of the output is after 5 min or on e.g. an "exit" butten the Websock bzzw the logging is terminated.

As I understood it should work like this, but step 3 closes the websock at the end of the logging process. For it to work the Javascript would have to rebuild the websock again and again. That would be the same with Ajax and because Ajax asks for time you want a websocket that can send / receive data bidirectional and reduce the html overhead.

Is it possible to implement this?
I try to give you the full understand what I need, if not please ask.
Or is that possible and I have overlooked how !

greeting
Jake

MKR1000 and WIFI problem and another problem

Describe the bug

I am running the sample program "SAMD-Minimal-Client", but it has a problem when it reaches any WIFI line.

Arduino IDE 1.8.15
Arduino MKR 1000
Installed libraries:
WiFiNINA_Generic v1.2.4
WebSockets2_Generic v1.8.5

sc10

Steps to Reproduce

When I compile the sample program I get some strange lines before finishing compilation (ScreenShot sc05.jpg).
I have added some lines to the code Serial.prinln ("1") ... (ScreenShot sc06.jpg) to see where the execution of the program goes.
As you will see in the screenshot, on the serial monitor, the program correctly detects my MKR1000, but it does not pass the Serial.print (1) line, that is, it remains blocked in WiFi.status () (ScreenShot sc07.jpg)
Even if you disable several lines in the program prior to the WiFi connection (ScreenShot sc08.jpg), it always stays blocked, even on the WiFi.begin line (ScreenShot sc09.jpg).
You can also see in the screenshots that I have used the firmware check programs and another example program from the Wifi101 library to check the WiFi connection and everything works perfectly (ScreenShots sc01, sc02, sc03, sc04). That is, the problem is when using your library.
Am I doing something wrong or is it a bug in your library?
Look at all the screenshots.

sc05
sc06
sc07
sc08
sc09

Checks:

CheckWifi101FirmwareVersion

sc01
sc02

WiFiWebClient

sc03
sc04

Thank you very much for your help.

Regards,
Jose.

Docs?

Are there any docs? API? The examples are helpful, but for instance, I'm not sure what exactly client.available() does, nor e.g. how many different callbacks are available. (Also, it looks like onEventsCallback in the README is never used?) The many-targeted nature of the code makes it hard to search the code for a definitive answer. It sounds like this project is based on another - is there other documentation elsewhere that is considered canon for this library, too?

WebSockets2_generic library and MKR1000 + Ethernet Shield

Hi Khoih,

I'm trying to use the WebSockets2_generic library with the Arduino MKR1000 + Ethernet Shield, but it can't even connect to the server.
I am using your example (SAMD-Ethernet-Client) which is prepared for the MKR1000.
I have installed the patches from the Ethernet library and the EthernetLarge library, but with neither of the 2 it manages to connect to the nodejs server.
Produces the following output:

12:18:04.435 -> 
12:18:04.435 -> Starting SAMD-Ethernet-Client on SAMD MKR1000
12:18:04.435 -> Ethernet using W5x00 and Ethernet Library
12:18:04.435 -> WebSockets2_Generic v1.8.1
12:18:04.982 -> 
12:18:04.982 -> W5100 init, using SS_PIN_DEFAULT = 5, new ss_pin = 10, W5100Class::ss_pin = 10
12:18:04.982 -> no chip :-(
12:18:04.982 -> WebSockets Client IP address: 0.0.0.0
12:18:04.982 -> Connecting to WebSockets Server @192.168.20.100
12:18:04.982 -> [WS] WebsocketsClient::connect: step 1
12:18:04.982 -> [WS] WebsocketsClient::connect: not _connectionOpen, host = 192.168.20.100 , port = 8080
12:18:04.982 -> Not Connected!

Your WebSockets_generic library manages to connect with socket.io, but your WebSockets2_generic library doesn't even connect.
According to your documentation the WebSockets2_generic library should work without problems with the MKR1000 + Ethernet Shield just like your WebSockets_generic library.

What could be happening?
I am doing something wrong?

Thanks for your help.
Regards,
Jose

Compiler warnings

Hello, I get many compiler warnings using Teensy 4.1 and native ethernet. Even if everything works perfectly, it pollutes the compiler output and it is not really helpfull. Anything to do about it?

[...]\Arduino\libraries\WebSockets2_Generic\src/Tiny_Websockets_Generic/message.hpp:58:6: warning: #warning WEBSOCKETS_USE_ETHERNET and USE_NATIVE_ETHERNET in client.hpp [-Wcpp] #warning WEBSOCKETS_USE_ETHERNET and USE_NATIVE_ETHERNET in client.hpp ^ In file included from [...]\Arduino\libraries\WebSockets2_Generic\src/Tiny_Websockets_Generic/message.hpp:59:0, from [...]\Arduino\libraries\WebSockets2_Generic\src/WebSockets2_Generic.h:48, from [...]\Arduino\web_server\web_server.ino:61: [...]\Arduino\libraries\WebSockets2_Generic\src/Tiny_Websockets_Generic/internals/ws_common_NativeEthernet.hpp:59:8: warning: #warning Using NativeEthernet for Teensy 4.1 in ws_common_NativeEthernet.hpp [-Wcpp] #warning Using NativeEthernet for Teensy 4.1 in ws_common_NativeEthernet.hpp ^ In file included from [...]\Arduino\libraries\WebSockets2_Generic\src/WebSockets2_Generic.h:49:0, from [...]\Arduino\web_server\web_server.ino:61: [...]\Arduino\libraries\WebSockets2_Generic\src/Tiny_Websockets_Generic/client.hpp:64:6: warning: #warning WEBSOCKETS_USE_ETHERNET and USE_NATIVE_ETHERNET in client.hpp [-Wcpp] #warning WEBSOCKETS_USE_ETHERNET and USE_NATIVE_ETHERNET in client.hpp ^ In file included from [...]\Arduino\libraries\WebSockets2_Generic\src/WebSockets2_Generic.h:50:0, from [...]\Arduino\web_server\web_server.ino:61: [...]\Arduino\libraries\WebSockets2_Generic\src/Tiny_Websockets_Generic/server.hpp:59:6: warning: #warning WEBSOCKETS_USE_ETHERNET and USE_NATIVE_ETHERNET in server.hpp [-Wcpp] #warning WEBSOCKETS_USE_ETHERNET and USE_NATIVE_ETHERNET in server.hpp ^

Thanks a lot for your work!

Missing stm32_def.h for Teensy 4.1

PlatformIO Core, version 5.1.0
Windows 10 Enterprise
Board: Teensy 4.1
Framework: Arduino

Hi, I am trying to build a project in PlatfromIO for the Teensy 4.1 with this library added to platform.ini. It does not compile successfully. I get the following error 8 times before the compilation is terminated:

".pio\libdeps\teensy41\STM32Ethernet\src\utility\stm32_eth.h:42:23: fatal error: stm32_def.h: No such file or directory"

Why would there be STM32 files under the teensy41 core?

My platform.ini file looks as follows:

[env:teensy41]
platform = teensy
board = teensy41
framework = arduino
lib_deps = 
    https://github.com/vjmuzik/FNET.git
    https://github.com/vjmuzik/NativeEthernet.git
    https://github.com/sstaub/TeensyID.git
    https://github.com/khoih-prog/WebSockets2_Generic.git

Steps to reproduce:

  1. Open PIO project for Teensy 4.1 board
  2. Add Github link for FNET to platformo.ini file: https://github.com/vjmuzik/FNET.git
  3. Add Github link for NativeEthernet to platformio.ini file: https://github.com/vjmuzik/NativeEthernet.git
  4. Add Github link for TeensyID to platformio.ini file: https://github.com/sstaub/TeensyID.git
  5. Add Github link for WebSockets2_Generic to platformio.ini file: https://github.com/khoih-prog/WebSockets2_Generic.git
  6. Build project

Fast Websocket sending causes stuttering?

I'm using an Arduino Nano 33 iot with the WifiNina client example. I'm sending over data every 16ms and the data all gets to where it needs to go although it stutters. It's as if I'm receiving the data in chunks rather than quickly every 16ms. Do you guys know of some reason this might occur? I'm trying to send string data which looks like "123,145,156,674" per message.

WebSockets2_Generic on Mega2560 with w5100 ethernet shield

Hello!
Is it possible to run this library on a Mega2560 with w5100 ethernet shield?
I want to set up my Alexa Gateway with Sinric over Lan.

I cannot find a working example for my setup and always get a compatibility error ("This code is intended to run on...").

Thanks in Advance!

Compile example failed

I'm trying to compile the example Esp8266-Server. Arduino IDE 1.8.5. I get compilation errors. Here's the log:

/home/erhannis/arduino-1.8.5/arduino-builder -dump-prefs -logger=machine -hardware /home/erhannis/arduino-1.8.5/hardware -hardware /home/erhannis/.arduino15/packages -tools /home/erhannis/arduino-1.8.5/tools-builder -tools /home/erhannis/arduino-1.8.5/hardware/tools/avr -tools /home/erhannis/.arduino15/packages -built-in-libraries /home/erhannis/arduino-1.8.5/libraries -libraries /home/erhannis/Arduino/libraries -fqbn=esp8266:esp8266:generic:CpuFrequency=80,ResetMethod=ck,CrystalFreq=26,FlashFreq=40,FlashMode=qio,FlashSize=512K0,led=2,LwIPVariant=v2mss536,Debug=Disabled,DebugLevel=None____,FlashErase=none,UploadSpeed=115200 -ide-version=10805 -build-path /tmp/arduino_build_250835 -warnings=none -build-cache /tmp/arduino_cache_89380 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.esptool.path=/home/erhannis/.arduino15/packages/esp8266/tools/esptool/0.4.13 -prefs=runtime.tools.xtensa-lx106-elf-gcc.path=/home/erhannis/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2 -prefs=runtime.tools.mkspiffs.path=/home/erhannis/.arduino15/packages/esp8266/tools/mkspiffs/0.2.0 -verbose /home/erhannis/clones/WebSockets2_Generic/examples/ESP8266/Esp8266-Server/Esp8266-Server.ino
/home/erhannis/arduino-1.8.5/arduino-builder -compile -logger=machine -hardware /home/erhannis/arduino-1.8.5/hardware -hardware /home/erhannis/.arduino15/packages -tools /home/erhannis/arduino-1.8.5/tools-builder -tools /home/erhannis/arduino-1.8.5/hardware/tools/avr -tools /home/erhannis/.arduino15/packages -built-in-libraries /home/erhannis/arduino-1.8.5/libraries -libraries /home/erhannis/Arduino/libraries -fqbn=esp8266:esp8266:generic:CpuFrequency=80,ResetMethod=ck,CrystalFreq=26,FlashFreq=40,FlashMode=qio,FlashSize=512K0,led=2,LwIPVariant=v2mss536,Debug=Disabled,DebugLevel=None____,FlashErase=none,UploadSpeed=115200 -ide-version=10805 -build-path /tmp/arduino_build_250835 -warnings=none -build-cache /tmp/arduino_cache_89380 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.esptool.path=/home/erhannis/.arduino15/packages/esp8266/tools/esptool/0.4.13 -prefs=runtime.tools.xtensa-lx106-elf-gcc.path=/home/erhannis/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2 -prefs=runtime.tools.mkspiffs.path=/home/erhannis/.arduino15/packages/esp8266/tools/mkspiffs/0.2.0 -verbose /home/erhannis/clones/WebSockets2_Generic/examples/ESP8266/Esp8266-Server/Esp8266-Server.ino
Using board 'generic' from platform in folder: /home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1
Using core 'esp8266' from platform in folder: /home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1
Build options changed, rebuilding all
Detecting libraries used...
"/home/erhannis/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/include" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/lwip2/include" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/libc/xtensa-lx106-elf/include" "-I/tmp/arduino_build_250835/core" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11  -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536   -DARDUINO=10805 -DARDUINO_ESP8266_GENERIC -DARDUINO_ARCH_ESP8266 -DARDUINO_BOARD="ESP8266_GENERIC" -DLED_BUILTIN=2  -DESP8266 "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/cores/esp8266" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/variants/generic" "/tmp/arduino_build_250835/sketch/Esp8266-Server.ino.cpp" -o "/dev/null"
"/home/erhannis/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/include" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/lwip2/include" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/libc/xtensa-lx106-elf/include" "-I/tmp/arduino_build_250835/core" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11  -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536   -DARDUINO=10805 -DARDUINO_ESP8266_GENERIC -DARDUINO_ARCH_ESP8266 -DARDUINO_BOARD="ESP8266_GENERIC" -DLED_BUILTIN=2  -DESP8266 "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/cores/esp8266" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/variants/generic" "-I/home/erhannis/Arduino/libraries/WebSockets2_Generic/src" "/tmp/arduino_build_250835/sketch/Esp8266-Server.ino.cpp" -o "/dev/null"
"/home/erhannis/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/include" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/lwip2/include" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/libc/xtensa-lx106-elf/include" "-I/tmp/arduino_build_250835/core" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11  -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536   -DARDUINO=10805 -DARDUINO_ESP8266_GENERIC -DARDUINO_ARCH_ESP8266 -DARDUINO_BOARD="ESP8266_GENERIC" -DLED_BUILTIN=2  -DESP8266 "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/cores/esp8266" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/variants/generic" "-I/home/erhannis/Arduino/libraries/WebSockets2_Generic/src" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/libraries/ESP8266WiFi/src" "/tmp/arduino_build_250835/sketch/Esp8266-Server.ino.cpp" -o "/dev/null"
"/home/erhannis/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/include" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/lwip2/include" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/libc/xtensa-lx106-elf/include" "-I/tmp/arduino_build_250835/core" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11  -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536   -DARDUINO=10805 -DARDUINO_ESP8266_GENERIC -DARDUINO_ARCH_ESP8266 -DARDUINO_BOARD="ESP8266_GENERIC" -DLED_BUILTIN=2  -DESP8266 "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/cores/esp8266" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/variants/generic" "-I/home/erhannis/Arduino/libraries/WebSockets2_Generic/src" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/libraries/ESP8266WiFi/src" "/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/libraries/ESP8266WiFi/src/ESP8266WiFi.cpp" -o "/dev/null"
"/home/erhannis/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/include" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/lwip2/include" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/libc/xtensa-lx106-elf/include" "-I/tmp/arduino_build_250835/core" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11  -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536   -DARDUINO=10805 -DARDUINO_ESP8266_GENERIC -DARDUINO_ARCH_ESP8266 -DARDUINO_BOARD="ESP8266_GENERIC" -DLED_BUILTIN=2  -DESP8266 "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/cores/esp8266" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/variants/generic" "-I/home/erhannis/Arduino/libraries/WebSockets2_Generic/src" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/libraries/ESP8266WiFi/src" "/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/libraries/ESP8266WiFi/src/ESP8266WiFiAP.cpp" -o "/dev/null"
"/home/erhannis/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/include" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/lwip2/include" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/libc/xtensa-lx106-elf/include" "-I/tmp/arduino_build_250835/core" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11  -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536   -DARDUINO=10805 -DARDUINO_ESP8266_GENERIC -DARDUINO_ARCH_ESP8266 -DARDUINO_BOARD="ESP8266_GENERIC" -DLED_BUILTIN=2  -DESP8266 "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/cores/esp8266" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/variants/generic" "-I/home/erhannis/Arduino/libraries/WebSockets2_Generic/src" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/libraries/ESP8266WiFi/src" "/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp" -o "/dev/null"
"/home/erhannis/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/include" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/lwip2/include" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/libc/xtensa-lx106-elf/include" "-I/tmp/arduino_build_250835/core" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11  -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536   -DARDUINO=10805 -DARDUINO_ESP8266_GENERIC -DARDUINO_ARCH_ESP8266 -DARDUINO_BOARD="ESP8266_GENERIC" -DLED_BUILTIN=2  -DESP8266 "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/cores/esp8266" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/variants/generic" "-I/home/erhannis/Arduino/libraries/WebSockets2_Generic/src" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/libraries/ESP8266WiFi/src" "/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/libraries/ESP8266WiFi/src/ESP8266WiFiMulti.cpp" -o "/dev/null"
"/home/erhannis/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/include" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/lwip2/include" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/libc/xtensa-lx106-elf/include" "-I/tmp/arduino_build_250835/core" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11  -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536   -DARDUINO=10805 -DARDUINO_ESP8266_GENERIC -DARDUINO_ARCH_ESP8266 -DARDUINO_BOARD="ESP8266_GENERIC" -DLED_BUILTIN=2  -DESP8266 "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/cores/esp8266" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/variants/generic" "-I/home/erhannis/Arduino/libraries/WebSockets2_Generic/src" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/libraries/ESP8266WiFi/src" "/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp" -o "/dev/null"
"/home/erhannis/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/include" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/lwip2/include" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/libc/xtensa-lx106-elf/include" "-I/tmp/arduino_build_250835/core" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11  -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536   -DARDUINO=10805 -DARDUINO_ESP8266_GENERIC -DARDUINO_ARCH_ESP8266 -DARDUINO_BOARD="ESP8266_GENERIC" -DLED_BUILTIN=2  -DESP8266 "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/cores/esp8266" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/variants/generic" "-I/home/erhannis/Arduino/libraries/WebSockets2_Generic/src" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/libraries/ESP8266WiFi/src" "/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/libraries/ESP8266WiFi/src/ESP8266WiFiScan.cpp" -o "/dev/null"
"/home/erhannis/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/include" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/lwip2/include" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/libc/xtensa-lx106-elf/include" "-I/tmp/arduino_build_250835/core" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11  -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536   -DARDUINO=10805 -DARDUINO_ESP8266_GENERIC -DARDUINO_ARCH_ESP8266 -DARDUINO_BOARD="ESP8266_GENERIC" -DLED_BUILTIN=2  -DESP8266 "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/cores/esp8266" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/variants/generic" "-I/home/erhannis/Arduino/libraries/WebSockets2_Generic/src" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/libraries/ESP8266WiFi/src" "/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/libraries/ESP8266WiFi/src/WiFiClient.cpp" -o "/dev/null"
"/home/erhannis/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/include" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/lwip2/include" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/libc/xtensa-lx106-elf/include" "-I/tmp/arduino_build_250835/core" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11  -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536   -DARDUINO=10805 -DARDUINO_ESP8266_GENERIC -DARDUINO_ARCH_ESP8266 -DARDUINO_BOARD="ESP8266_GENERIC" -DLED_BUILTIN=2  -DESP8266 "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/cores/esp8266" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/variants/generic" "-I/home/erhannis/Arduino/libraries/WebSockets2_Generic/src" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/libraries/ESP8266WiFi/src" "/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/libraries/ESP8266WiFi/src/WiFiClientSecure.cpp" -o "/dev/null"
"/home/erhannis/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/include" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/lwip2/include" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/libc/xtensa-lx106-elf/include" "-I/tmp/arduino_build_250835/core" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11  -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536   -DARDUINO=10805 -DARDUINO_ESP8266_GENERIC -DARDUINO_ARCH_ESP8266 -DARDUINO_BOARD="ESP8266_GENERIC" -DLED_BUILTIN=2  -DESP8266 "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/cores/esp8266" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/variants/generic" "-I/home/erhannis/Arduino/libraries/WebSockets2_Generic/src" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/libraries/ESP8266WiFi/src" "/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/libraries/ESP8266WiFi/src/WiFiServer.cpp" -o "/dev/null"
"/home/erhannis/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/include" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/lwip2/include" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/libc/xtensa-lx106-elf/include" "-I/tmp/arduino_build_250835/core" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11  -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536   -DARDUINO=10805 -DARDUINO_ESP8266_GENERIC -DARDUINO_ARCH_ESP8266 -DARDUINO_BOARD="ESP8266_GENERIC" -DLED_BUILTIN=2  -DESP8266 "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/cores/esp8266" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/variants/generic" "-I/home/erhannis/Arduino/libraries/WebSockets2_Generic/src" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/libraries/ESP8266WiFi/src" "/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/libraries/ESP8266WiFi/src/WiFiServerSecure.cpp" -o "/dev/null"
"/home/erhannis/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/include" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/lwip2/include" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/libc/xtensa-lx106-elf/include" "-I/tmp/arduino_build_250835/core" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11  -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536   -DARDUINO=10805 -DARDUINO_ESP8266_GENERIC -DARDUINO_ARCH_ESP8266 -DARDUINO_BOARD="ESP8266_GENERIC" -DLED_BUILTIN=2  -DESP8266 "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/cores/esp8266" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/variants/generic" "-I/home/erhannis/Arduino/libraries/WebSockets2_Generic/src" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/libraries/ESP8266WiFi/src" "/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/libraries/ESP8266WiFi/src/WiFiUdp.cpp" -o "/dev/null"
Generating function prototypes...
"/home/erhannis/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/include" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/lwip2/include" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/libc/xtensa-lx106-elf/include" "-I/tmp/arduino_build_250835/core" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11  -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536   -DARDUINO=10805 -DARDUINO_ESP8266_GENERIC -DARDUINO_ARCH_ESP8266 -DARDUINO_BOARD="ESP8266_GENERIC" -DLED_BUILTIN=2  -DESP8266 "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/cores/esp8266" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/variants/generic" "-I/home/erhannis/Arduino/libraries/WebSockets2_Generic/src" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/libraries/ESP8266WiFi/src" "/tmp/arduino_build_250835/sketch/Esp8266-Server.ino.cpp" -o "/tmp/arduino_build_250835/preproc/ctags_target_for_gcc_minus_e.cpp"
"/home/erhannis/arduino-1.8.5/tools-builder/ctags/5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "/tmp/arduino_build_250835/preproc/ctags_target_for_gcc_minus_e.cpp"
Compiling sketch...
"/home/erhannis/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/include" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/lwip2/include" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/tools/sdk/libc/xtensa-lx106-elf/include" "-I/tmp/arduino_build_250835/core" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11 -MMD -ffunction-sections -fdata-sections -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536   -DARDUINO=10805 -DARDUINO_ESP8266_GENERIC -DARDUINO_ARCH_ESP8266 -DARDUINO_BOARD="ESP8266_GENERIC" -DLED_BUILTIN=2  -DESP8266 "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/cores/esp8266" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/variants/generic" "-I/home/erhannis/Arduino/libraries/WebSockets2_Generic/src" "-I/home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/libraries/ESP8266WiFi/src" "/tmp/arduino_build_250835/sketch/Esp8266-Server.ino.cpp" -o "/tmp/arduino_build_250835/sketch/Esp8266-Server.ino.cpp.o"
In file included from /home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/internals/ws_common.hpp:58:0,
                 from /home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/internals/data_frame.hpp:30,
                 from /home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/message.hpp:33,
                 from /home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic.h:35,
                 from /home/erhannis/clones/WebSockets2_Generic/examples/ESP8266/Esp8266-Server/Esp8266-Server.ino:38:
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/network/esp8266/esp8266_tcp.hpp:60:32: error: 'PublicKey' does not name a type
         void setKnownKey(const PublicKey *pk) 
                                ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/network/esp8266/esp8266_tcp.hpp:60:43: error: ISO C++ forbids declaration of 'pk' with no type [-fpermissive]
         void setKnownKey(const PublicKey *pk) 
                                           ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/network/esp8266/esp8266_tcp.hpp:65:36: error: 'X509List' does not name a type
         void setTrustAnchors(const X509List *ta)
                                    ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/network/esp8266/esp8266_tcp.hpp:65:46: error: ISO C++ forbids declaration of 'ta' with no type [-fpermissive]
         void setTrustAnchors(const X509List *ta)
                                              ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/network/esp8266/esp8266_tcp.hpp:70:37: error: 'X509List' does not name a type
         void setClientRSACert(const X509List *cert, const PrivateKey *sk) 
                                     ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/network/esp8266/esp8266_tcp.hpp:70:47: error: ISO C++ forbids declaration of 'cert' with no type [-fpermissive]
         void setClientRSACert(const X509List *cert, const PrivateKey *sk) 
                                               ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/network/esp8266/esp8266_tcp.hpp:70:59: error: 'PrivateKey' does not name a type
         void setClientRSACert(const X509List *cert, const PrivateKey *sk) 
                                                           ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/network/esp8266/esp8266_tcp.hpp:70:71: error: ISO C++ forbids declaration of 'sk' with no type [-fpermissive]
         void setClientRSACert(const X509List *cert, const PrivateKey *sk) 
                                                                       ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/network/esp8266/esp8266_tcp.hpp:75:36: error: 'X509List' does not name a type
         void setClientECCert(const X509List *cert, const PrivateKey *sk) 
                                    ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/network/esp8266/esp8266_tcp.hpp:75:46: error: ISO C++ forbids declaration of 'cert' with no type [-fpermissive]
         void setClientECCert(const X509List *cert, const PrivateKey *sk) 
                                              ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/network/esp8266/esp8266_tcp.hpp:75:58: error: 'PrivateKey' does not name a type
         void setClientECCert(const X509List *cert, const PrivateKey *sk) 
                                                          ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/network/esp8266/esp8266_tcp.hpp:75:70: error: ISO C++ forbids declaration of 'sk' with no type [-fpermissive]
         void setClientECCert(const X509List *cert, const PrivateKey *sk) 
                                                                      ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/network/esp8266/esp8266_tcp.hpp: In member function 'void websockets2_generic::network2_generic::SecuredEsp8266TcpClient::setInsecure()':
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/network/esp8266/esp8266_tcp.hpp:50:24: error: 'class WiFiClientSecure' has no member named 'setInsecure'
           this->client.setInsecure();
                        ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/network/esp8266/esp8266_tcp.hpp: In member function 'void websockets2_generic::network2_generic::SecuredEsp8266TcpClient::setFingerprint(const char*)':
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/network/esp8266/esp8266_tcp.hpp:55:24: error: 'class WiFiClientSecure' has no member named 'setFingerprint'
           this->client.setFingerprint(fingerprint);
                        ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/network/esp8266/esp8266_tcp.hpp: In member function 'void websockets2_generic::network2_generic::SecuredEsp8266TcpClient::setKnownKey(const int*)':
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/network/esp8266/esp8266_tcp.hpp:62:24: error: 'class WiFiClientSecure' has no member named 'setKnownKey'
           this->client.setKnownKey(pk);
                        ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/network/esp8266/esp8266_tcp.hpp: In member function 'void websockets2_generic::network2_generic::SecuredEsp8266TcpClient::setTrustAnchors(const int*)':
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/network/esp8266/esp8266_tcp.hpp:67:24: error: 'class WiFiClientSecure' has no member named 'setTrustAnchors'
           this->client.setTrustAnchors(ta);
                        ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/network/esp8266/esp8266_tcp.hpp: In member function 'void websockets2_generic::network2_generic::SecuredEsp8266TcpClient::setClientRSACert(const int*, const int*)':
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/network/esp8266/esp8266_tcp.hpp:72:24: error: 'class WiFiClientSecure' has no member named 'setClientRSACert'
           this->client.setClientRSACert(cert, sk);
                        ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/network/esp8266/esp8266_tcp.hpp: In member function 'void websockets2_generic::network2_generic::SecuredEsp8266TcpClient::setClientECCert(const int*, const int*)':
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/network/esp8266/esp8266_tcp.hpp:77:24: error: 'class WiFiClientSecure' has no member named 'setClientECCert'
           this->client.setClientECCert(cert, sk, 0xFFFF, 0);
                        ^
In file included from /home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic.h:36:0,
                 from /home/erhannis/clones/WebSockets2_Generic/examples/ESP8266/Esp8266-Server/Esp8266-Server.ino:38:
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/client.hpp: At global scope:
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/client.hpp:148:35: error: 'X509List' does not name a type
       void setClientRSACert(const X509List *cert, const PrivateKey *sk);
                                   ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/client.hpp:148:45: error: ISO C++ forbids declaration of 'cert' with no type [-fpermissive]
       void setClientRSACert(const X509List *cert, const PrivateKey *sk);
                                             ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/client.hpp:148:57: error: 'PrivateKey' does not name a type
       void setClientRSACert(const X509List *cert, const PrivateKey *sk);
                                                         ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/client.hpp:148:69: error: ISO C++ forbids declaration of 'sk' with no type [-fpermissive]
       void setClientRSACert(const X509List *cert, const PrivateKey *sk);
                                                                     ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/client.hpp:150:34: error: 'X509List' does not name a type
       void setClientECCert(const X509List *cert, const PrivateKey *sk);
                                  ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/client.hpp:150:44: error: ISO C++ forbids declaration of 'cert' with no type [-fpermissive]
       void setClientECCert(const X509List *cert, const PrivateKey *sk);
                                            ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/client.hpp:150:56: error: 'PrivateKey' does not name a type
       void setClientECCert(const X509List *cert, const PrivateKey *sk);
                                                        ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/client.hpp:150:68: error: ISO C++ forbids declaration of 'sk' with no type [-fpermissive]
       void setClientECCert(const X509List *cert, const PrivateKey *sk);
                                                                    ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/client.hpp:151:34: error: 'X509List' does not name a type
       void setTrustAnchors(const X509List *ta);
                                  ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/client.hpp:151:44: error: ISO C++ forbids declaration of 'ta' with no type [-fpermissive]
       void setTrustAnchors(const X509List *ta);
                                            ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/client.hpp:152:30: error: 'PublicKey' does not name a type
       void setKnownKey(const PublicKey *pk);
                              ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/client.hpp:152:41: error: ISO C++ forbids declaration of 'pk' with no type [-fpermissive]
       void setKnownKey(const PublicKey *pk);
                                         ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/client.hpp:187:13: error: 'X509List' does not name a type
       const X509List* _optional_ssl_trust_anchors = nullptr;
             ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/client.hpp:190:13: error: 'PublicKey' does not name a type
       const PublicKey* _optional_ssl_known_key = nullptr;
             ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/client.hpp:191:13: error: 'X509List' does not name a type
       const X509List* _optional_ssl_rsa_cert = nullptr;
             ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/client.hpp:192:13: error: 'PrivateKey' does not name a type
       const PrivateKey* _optional_ssl_rsa_private_key = nullptr;
             ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/client.hpp:193:13: error: 'X509List' does not name a type
       const X509List* _optional_ssl_ec_cert = nullptr;
             ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/Tiny_Websockets_Generic/client.hpp:194:13: error: 'PrivateKey' does not name a type
       const PrivateKey* _optional_ssl_ec_private_key = nullptr; 
             ^
In file included from /home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic.h:40:0,
                 from /home/erhannis/clones/WebSockets2_Generic/examples/ESP8266/Esp8266-Server/Esp8266-Server.ino:38:
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp: In member function 'void websockets2_generic::WebsocketsClient::upgradeToSecuredConnection()':
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:391:23: error: 'class websockets2_generic::WebsocketsClient' has no member named '_optional_ssl_rsa_cert'
            ||  (this->_optional_ssl_rsa_cert && this->_optional_ssl_rsa_private_key)
                       ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:391:55: error: 'class websockets2_generic::WebsocketsClient' has no member named '_optional_ssl_rsa_private_key'
            ||  (this->_optional_ssl_rsa_cert && this->_optional_ssl_rsa_private_key)
                                                       ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:392:23: error: 'class websockets2_generic::WebsocketsClient' has no member named '_optional_ssl_ec_cert'
            ||  (this->_optional_ssl_ec_cert && this->_optional_ssl_ec_private_key)
                       ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:392:54: error: 'class websockets2_generic::WebsocketsClient' has no member named '_optional_ssl_ec_private_key'
            ||  (this->_optional_ssl_ec_cert && this->_optional_ssl_ec_private_key)
                                                      ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:393:22: error: 'class websockets2_generic::WebsocketsClient' has no member named '_optional_ssl_trust_anchors'
            ||  this->_optional_ssl_trust_anchors
                      ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:394:22: error: 'class websockets2_generic::WebsocketsClient' has no member named '_optional_ssl_known_key'
            ||  this->_optional_ssl_known_key)
                      ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:401:17: error: 'class websockets2_generic::WebsocketsClient' has no member named '_optional_ssl_trust_anchors'
       if (this->_optional_ssl_trust_anchors) 
                 ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:403:39: error: 'class websockets2_generic::WebsocketsClient' has no member named '_optional_ssl_trust_anchors'
         client->setTrustAnchors(this->_optional_ssl_trust_anchors);
                                       ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:406:17: error: 'class websockets2_generic::WebsocketsClient' has no member named '_optional_ssl_known_key'
       if (this->_optional_ssl_known_key) 
                 ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:408:35: error: 'class websockets2_generic::WebsocketsClient' has no member named '_optional_ssl_known_key'
         client->setKnownKey(this->_optional_ssl_known_key);
                                   ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:411:17: error: 'class websockets2_generic::WebsocketsClient' has no member named '_optional_ssl_rsa_cert'
       if (this->_optional_ssl_rsa_cert && this->_optional_ssl_rsa_private_key) 
                 ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:411:49: error: 'class websockets2_generic::WebsocketsClient' has no member named '_optional_ssl_rsa_private_key'
       if (this->_optional_ssl_rsa_cert && this->_optional_ssl_rsa_private_key) 
                                                 ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:413:40: error: 'class websockets2_generic::WebsocketsClient' has no member named '_optional_ssl_rsa_cert'
         client->setClientRSACert(this->_optional_ssl_rsa_cert, this->_optional_ssl_rsa_private_key);
                                        ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:413:70: error: 'class websockets2_generic::WebsocketsClient' has no member named '_optional_ssl_rsa_private_key'
         client->setClientRSACert(this->_optional_ssl_rsa_cert, this->_optional_ssl_rsa_private_key);
                                                                      ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:416:17: error: 'class websockets2_generic::WebsocketsClient' has no member named '_optional_ssl_ec_cert'
       if (this->_optional_ssl_ec_cert && this->_optional_ssl_ec_private_key) 
                 ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:416:48: error: 'class websockets2_generic::WebsocketsClient' has no member named '_optional_ssl_ec_private_key'
       if (this->_optional_ssl_ec_cert && this->_optional_ssl_ec_private_key) 
                                                ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:418:39: error: 'class websockets2_generic::WebsocketsClient' has no member named '_optional_ssl_ec_cert'
         client->setClientECCert(this->_optional_ssl_ec_cert, this->_optional_ssl_ec_private_key);
                                       ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:418:68: error: 'class websockets2_generic::WebsocketsClient' has no member named '_optional_ssl_ec_private_key'
         client->setClientECCert(this->_optional_ssl_ec_cert, this->_optional_ssl_ec_private_key);
                                                                    ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp: In member function 'void websockets2_generic::WebsocketsClient::setInsecure()':
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:950:11: error: 'class websockets2_generic::WebsocketsClient' has no member named '_optional_ssl_rsa_cert'
     this->_optional_ssl_rsa_cert = nullptr;
           ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:951:11: error: 'class websockets2_generic::WebsocketsClient' has no member named '_optional_ssl_rsa_private_key'
     this->_optional_ssl_rsa_private_key = nullptr;
           ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:952:11: error: 'class websockets2_generic::WebsocketsClient' has no member named '_optional_ssl_ec_cert'
     this->_optional_ssl_ec_cert = nullptr;
           ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:953:11: error: 'class websockets2_generic::WebsocketsClient' has no member named '_optional_ssl_ec_private_key'
     this->_optional_ssl_ec_private_key = nullptr;
           ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:954:11: error: 'class websockets2_generic::WebsocketsClient' has no member named '_optional_ssl_trust_anchors'
     this->_optional_ssl_trust_anchors = nullptr;
           ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:955:11: error: 'class websockets2_generic::WebsocketsClient' has no member named '_optional_ssl_known_key'
     this->_optional_ssl_known_key = nullptr;
           ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp: At global scope:
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:958:49: error: 'X509List' does not name a type
   void WebsocketsClient::setClientRSACert(const X509List *cert, const PrivateKey *sk) 
                                                 ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:958:59: error: ISO C++ forbids declaration of 'cert' with no type [-fpermissive]
   void WebsocketsClient::setClientRSACert(const X509List *cert, const PrivateKey *sk) 
                                                           ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:958:71: error: 'PrivateKey' does not name a type
   void WebsocketsClient::setClientRSACert(const X509List *cert, const PrivateKey *sk) 
                                                                       ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:958:83: error: ISO C++ forbids declaration of 'sk' with no type [-fpermissive]
   void WebsocketsClient::setClientRSACert(const X509List *cert, const PrivateKey *sk) 
                                                                                   ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp: In member function 'void websockets2_generic::WebsocketsClient::setClientRSACert(const int*, const int*)':
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:960:11: error: 'class websockets2_generic::WebsocketsClient' has no member named '_optional_ssl_rsa_cert'
     this->_optional_ssl_rsa_cert = cert;
           ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:961:11: error: 'class websockets2_generic::WebsocketsClient' has no member named '_optional_ssl_rsa_private_key'
     this->_optional_ssl_rsa_private_key = sk;
           ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp: At global scope:
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:964:48: error: 'X509List' does not name a type
   void WebsocketsClient::setClientECCert(const X509List *cert, const PrivateKey *sk) 
                                                ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:964:58: error: ISO C++ forbids declaration of 'cert' with no type [-fpermissive]
   void WebsocketsClient::setClientECCert(const X509List *cert, const PrivateKey *sk) 
                                                          ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:964:70: error: 'PrivateKey' does not name a type
   void WebsocketsClient::setClientECCert(const X509List *cert, const PrivateKey *sk) 
                                                                      ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:964:82: error: ISO C++ forbids declaration of 'sk' with no type [-fpermissive]
   void WebsocketsClient::setClientECCert(const X509List *cert, const PrivateKey *sk) 
                                                                                  ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp: In member function 'void websockets2_generic::WebsocketsClient::setClientECCert(const int*, const int*)':
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:966:11: error: 'class websockets2_generic::WebsocketsClient' has no member named '_optional_ssl_ec_cert'
     this->_optional_ssl_ec_cert = cert;
           ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:967:11: error: 'class websockets2_generic::WebsocketsClient' has no member named '_optional_ssl_ec_private_key'
     this->_optional_ssl_ec_private_key = sk;
           ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp: At global scope:
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:970:48: error: 'X509List' does not name a type
   void WebsocketsClient::setTrustAnchors(const X509List *ta) 
                                                ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:970:58: error: ISO C++ forbids declaration of 'ta' with no type [-fpermissive]
   void WebsocketsClient::setTrustAnchors(const X509List *ta) 
                                                          ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp: In member function 'void websockets2_generic::WebsocketsClient::setTrustAnchors(const int*)':
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:972:11: error: 'class websockets2_generic::WebsocketsClient' has no member named '_optional_ssl_trust_anchors'
     this->_optional_ssl_trust_anchors = ta;
           ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp: At global scope:
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:975:44: error: 'PublicKey' does not name a type
   void WebsocketsClient::setKnownKey(const PublicKey *pk) 
                                            ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:975:55: error: ISO C++ forbids declaration of 'pk' with no type [-fpermissive]
   void WebsocketsClient::setKnownKey(const PublicKey *pk) 
                                                       ^
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp: In member function 'void websockets2_generic::WebsocketsClient::setKnownKey(const int*)':
/home/erhannis/Arduino/libraries/WebSockets2_Generic/src/WebSockets2_Generic_Client.hpp:977:11: error: 'class websockets2_generic::WebsocketsClient' has no member named '_optional_ssl_known_key'
     this->_optional_ssl_known_key = pk;
           ^
Using library WebSockets2_Generic at version 1.1.0 in folder: /home/erhannis/Arduino/libraries/WebSockets2_Generic 
Using library ESP8266WiFi at version 1.0 in folder: /home/erhannis/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/libraries/ESP8266WiFi 
exit status 1
Error compiling for board Generic ESP8266 Module.

ESP32-Server Not Working Properly

i have uploaded esp32 server code from examples.
image

This is my program

/****************************************************************************************************************************
  ESP32-Server.ino
  For ESP32.

  Based on and modified from Gil Maimon's ArduinoWebsockets library https://github.com/gilmaimon/ArduinoWebsockets
  to support STM32F/L/H/G/WB/MP1, nRF52 and SAMD21/SAMD51 boards besides ESP8266 and ESP32


  The library provides simple and easy interface for websockets (Client and Server).

  Built by Khoi Hoang https://github.com/khoih-prog/Websockets2_Generic
  Licensed under MIT license
 *****************************************************************************************************************************/
/****************************************************************************************************************************
  ESP32 Websockets Server : Minimal ESP32 Websockets Server

  This sketch:
        1. Connects to a WiFi network
        2. Starts a websocket server on port 8080
        3. Waits for connections
        4. Once a client connects, it wait for a message from the client
        5. Sends an "echo" message to the client
        6. closes the connection and goes back to step 3

  Hardware:
        For this sketch you only need an ESP32 board.

  Originally Created  : 15/02/2019
  Original Author     : By Gil Maimon
  Original Repository : https://github.com/gilmaimon/ArduinoWebsockets

*****************************************************************************************************************************/

#include "defines.h"

#define DEBUG_LOCAL   2

#include <WebSockets2_Generic.h>
#include <WiFi.h>

using namespace websockets2_generic;

WebsocketsServer server;

void heartBeatPrint(void)
{
  static int num = 1;

  if (WiFi.status() == WL_CONNECTED)
    Serial.print("H");        // H means server WiFi connected
  else
    Serial.print("F");        // F means server WiFi not connected

  if (num == 80)
  {
    Serial.println();
    num = 1;
  }
  else if (num++ % 10 == 0)
  {
    Serial.print(" ");
  }
}

void check_status()
{
  static unsigned long checkstatus_timeout = 0;

  //KH
#define HEARTBEAT_INTERVAL    10000L
  // Print hearbeat every HEARTBEAT_INTERVAL (10) seconds.
  if ((millis() > checkstatus_timeout) || (checkstatus_timeout == 0))
  {
    heartBeatPrint();
    checkstatus_timeout = millis() + HEARTBEAT_INTERVAL;
  }
}

void setup()
{
  Serial.begin(115200);
  while (!Serial);

  Serial.print("\nStart ESP32-Server on ");
  Serial.println(ARDUINO_BOARD);
  Serial.println(WEBSOCKETS2_GENERIC_VERSION);

  //  WiFi.mode(WIFI_STA);

  //  WiFi.config(serverIP, static_GW, static_SN);

  // Connect to wifi
  WiFi.begin(ssid, password);

  // Wait some time to connect to wifi
  for (int i = 0; i < 15 && WiFi.status() != WL_CONNECTED; i++)
  {
    Serial.print(".");
    delay(1000);
  }

  if (WiFi.status() == WL_CONNECTED)
    Serial.println("\nWiFi connected");
  else
  {
    Serial.println("\nNo WiFi");
    return;
  }



  Serial.print(server.available() ? "WebSockets Server Running and Ready on " : "Server Not Running on ");
  server.listen(WEBSOCKETS_PORT);
  Serial.println(BOARD_NAME);
  Serial.print("IP address: ");
  Serial.print(WiFi.localIP());     //You can get IP address assigned to SAMD
  Serial.print(", Port: ");
  Serial.println(WEBSOCKETS_PORT);    // Websockets Server Port
}

void loop()
{
   check_status();

  WebsocketsClient client = server.accept();

    if (client.available())
    {
  WebsocketsMessage msg = client.readNonBlocking();
  WebsocketsMessage msg = client.readBlocking();

  // log
  Serial.print("Got Message: ");
  Serial.println(msg.data());

  // return echo
      client.send("Echo: " + msg.data());

  // close the connection
  //    client.close();
  }
  client.ping();
  //delay(1000);
}

PROBLEM IS
Client gets connected to server but after delivering 1 msg it gets disconnected. i tgried another libraries client code works properly. while code keeps me disconnecting and doesnt receive any other msg.


image

any help will be great for us.
thank you in advance

RP2040 WebSocket immediate disconnection

Bug

Starting from "RP2040_ServerAllFunctionsDemo.ino" from File > Examples > WebSockets2_Generic > Generic > WiFiNINA > RP2040 .
After some fixes (explained below) I can connect but I cannot maintain the communication open.

Steps to Reproduce

  • Used generic RP2040_ServerAllFunctionsDemo.ino from File > Examples > WebSockets2_Generic > Generic > WiFiNINA > RP2040 .
  • Set correct ssid and password in defines.h
  • Set the correct wsServer url in line 100
  • Went to the ip address:80 and saw the RGB sliders

Expected behavior

Socket connection opened and communication happening (not interested in RGB to really work but the communication to being established).

Actual behavior


PROBLEM: Javascript error: "Uncaught ReferenceError: wsServer is not defined" .

SOLUTION: Solved by replacing in line 106 this:
var connection = new WebSocket(wsServer, ['arduino']);
with:
var connection = new WebSocket('ws://'+window.location.hostname+':8080/', ['arduino']);
Compiled and uploaded new code.

RESULT: problem 1 solved, but I receive "WebSocket Error"


PROBLEM: WebSocket Error

SOLUTION: Solved by developing my own script available below:

    var wsClientOutput;

    function init() {
        testWebSocket();
    }

    function testWebSocket() {
        websocket = new WebSocket("ws://192.168.2.123:8080/"); //change with yours
        websocket.onopen = function (evt) {
            onOpen(evt)
        };
        websocket.onclose = function (evt) {
            onClose(evt)
        };
        websocket.onmessage = function (evt) {
            onMessage(evt)
        };
        websocket.onerror = function (evt) {
            onError(evt)
        };
    }

    function onOpen(evt) {
       console.log("OPEN")
    }

    function onClose(evt) {
        console.log("DISCONNECTED");
    }

    function onMessage(evt) {
        console.log('RESPONSE: ' + evt.data);
    }

    function onError(evt) {
        console.log('ERROR:' + evt.data);
    }

    function doSend(message) {
        console.log("SENT: " + message);
        websocket.send(message);
    }

   
    window.addEventListener("load", init, false);

RESULT: I can connect but I quickly disconnect.


PROBLEM: Immediate disconnection after connection

SOLUTION: I removed line 140 and line 143 from "RP2040_ServerAllFunctionsDemo.ino "
Compiled and uploaded new code.

RESULT: same error. Immediate disconnection after connection.

Information

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

  • Arduino IDE version: 2.0.3
  • RP2040 Core Version: Arduino-mbed OS Nano 3.5.4
  • RP2040 Board type: NANO_RP2040_CONNECT
  • Contextual information: maintain connection without automatic disconnection and stream some sensors values.
  • Operating system (Windows, Ubuntu, etc.): Windows 10
  • Network: Wi-Fi

not compiling on Arduino DUE with WIZnet W5500-Ethernet shield with SD-slot, IDE: 1.8.14

Hi!
could u help me? Dont know what Im doing wrong. Example: SAMDUE-Ethernet_ServerAllFunctionsDemo.
It s the same with SAMDUE-Ethernet-Server.

I had succes with (WebSockets-Lib)<WebSocketsServer.h> together with <Ethernet.h> but the problem is, that the Websocketsserver.cpp filled the Memory with one and the same client during first connection until he cleaned up everyone because >4 Clients

my shield:
https://www.mouser.de/ProductDetail/WIZnet/W5500-Ethernet-Shield?qs=k5OWtXsTJapDzGtdLOlnnw==

C:\Users\myName\AppData\Local\Temp\arduino_modified_sketch_842186/SAMDUE-Ethernet_ServerAllFunctionsDemo.ino:143: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
collect2.exe: error: ld returned 1 exit status
Using library EthernetLarge in folder: C:\Program Files (x86)\arduino-nightly\libraries\EthernetLarge (legacy)
Using library WebSockets2_Generic at version 1.0.7 in folder: C:\Users\myName\Documents\Arduino\libraries\WebSockets2_Generic 
Using library EthernetWebServer at version 1.1.0 in folder: C:\Users\myName\Documents\Arduino\libraries\EthernetWebServer 
Using library Functional-Vlpp at version 1.0.1 in folder: C:\Users\myName\Documents\Arduino\libraries\Functional-Vlpp 
Using library SPI at version 1.0 in folder: C:\Users\myName\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.12\libraries\SPI 
Using library Ethernet at version 2.0.0 in folder: C:\Users\myName\Documents\Arduino\libraries\Ethernet 
exit status 1
Error compiling for board Arduino Due (Programming Port).

my defines.h:

#ifndef defines_h
#define defines_h

#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) )
  #if defined(WEBSOCKETS_ETHERNET_USE_SAMDUE)
    #undef WEBSOCKETS_ETHERNET_USE_SAMDUE
  #endif
  #define WEBSOCKETS_USE_ETHERNET             true
  #define WEBSOCKETS_ETHERNET_USE_SAMDUE      true
#else
  #error This code is intended to run only on the SAM DUE boards ! Please check your Tools->Board setting.
#endif

#if defined(WEBSOCKETS_ETHERNET_USE_SAMDUE)

// For SAM DUE
#if defined(ARDUINO_SAM_DUE)
#define BOARD_TYPE      "SAM DUE"
#elif defined(__SAM3X8E__)
#define BOARD_TYPE      "SAM SAM3X8E"
#else
#define BOARD_TYPE      "SAM Unknown"
#endif

#endif

#if defined(ARDUINO_BOARD)
  #define BOARD_NAME    ARDUINO_BOARD
#else
  #ifndef BOARD_NAME
    #define BOARD_NAME    BOARD_TYPE
  #endif
#endif

// Just select one to be true. If all is false, default is Ethernet. 
// If more than one are true, the priority is USE_ETHERNET, USE_ETHERNET2, USE_ETHERNET_LARGE, USE_UIP_ETHERNET
#define USE_ETHERNET                  false
#define USE_ETHERNET2                 false
#define USE_ETHERNET_LARGE            true
#define USE_ETHERNET_ENC              false

#define USE_UIP_ETHERNET              false

#if USE_ETHERNET
  // Also default to Ethernet library
  #include <Ethernet.h>
  #define ETHERNET_TYPE               "W5x00 and Ethernet Library"
#elif USE_ETHERNET2
  #include <Ethernet2.h>
  #define ETHERNET_TYPE               "W5x00 and Ethernet2 Library"
#elif USE_ETHERNET_LARGE
  #include <EthernetLarge.h>
  #define ETHERNET_TYPE               "W5x00 and EthernetLarge Library"
#elif USE_ETHERNET_ENC
  #include <EthernetENC.h>
  #define ETHERNET_TYPE               "ENC28J60 and EthernetENC Library"  
#elif USE_UIP_ETHERNET
  #include <UIPEthernet.h>
  #include <utility/logging.h> 
  #define ETHERNET_TYPE               "ENC28J60 and UIPEthernet Library"
#else
  // Default to Ethernet library
  #include <Ethernet.h>
  #define ETHERNET_TYPE               "W5x00 and Ethernet Library"
#endif

WebSocket doesn't connect without a CA certificate.

I am using NodeMcu 32s with WebSockets2_Generic v1.1.0
As per the documentation CA cert is not necessary.
3
But I can't find a way to connect without a CA cert.
In my previous library for Esp 8266 it works without a CA cert.
but it not provide this feature for Esp32.

I need a persistent connection without worry about CA cert validity.

multiple definition of `websockets2_generic::WebsocketsServer::~WebsocketsServer()' in websocket2_generic library

HI.

Iโ€™m using โ€˜adafruit feather m0โ€™ board with w5500 and I succeed to run example code โ€œSAMD-Ethernet-Clientโ€. Also, I communicate server using websocket2_generic library. Then I want to separate code into two files.

While I was trying to make separate WebSocket header file using websockets2_generic library, I face weird error. I try to figure out it, but It was very complicated with my codes. Thus, I remove all of my code except necessary things such as โ€œ#defineโ€ and โ€œ#includeโ€.

I have four files which is

SAMD-Ethernet-Client.ino
EthernetWebSocketsClient.h
EthernetWebSocketsClient.cpp
defines.h

As the file name, I use the example code. defines.h is almost same with example code. I just remove unnecessary global values.
Other files are same below.

SAMD-Ethernet-Client.ino

#include "EthernetWebSocketsClient.h"
    
void setup()
{}
    
void loop()
{}

EthernetWebSocketsClient.h

#ifndef EWC_H
#define EWC_H
    
#include "defines.h"
#include <WebSockets2_Generic.h>
     
#endif

EthernetWebSocketsClient.cpp

#include "EthernetWebSocketsClient.h"

As I mentioned before, I remove all the code. Those are the full code. When compiling, it shows error like below

c:/users/chanyoung/appdata/local/arduino15/packages/adafruit/tools/arm-none-eabi-gcc/9-2019q4/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\CHANYO1\AppData\Local\Temp\arduino_build_4918\sketch\SAMD-Ethernet-Client.ino.cpp.o: in function std::function<void (websockets2_generic::WebsocketsClient&, websockets2_generic::WebsocketsMessage)>::operator bool() const': C:\Arduino\libraries\WebSockets2_Generic-master\src/Tiny_Websockets_Generic/internals/wscrypto/sha1.hpp:73: multiple definition of websockets2_generic::WebsocketsServer::WebsocketsServer()'; C:\Users\CHANYO1\AppData\Local\Temp\arduino_build_4918\sketch\EthernetWebSocketsClient.cpp.o:C:\Arduino\libraries\WebSockets2_Generic-master\src/WebSockets2_Generic_Server.hpp:182: first defined here
c:/users/chanyoung/appdata/local/arduino15/packages/adafruit/tools/arm-none-eabi-gcc/9-2019q4/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\CHANYO
1\AppData\Local\Temp\arduino_build_4918\sketch\SAMD-Ethernet-Client.ino.cpp.o: in function std::function<void (websockets2_generic::WebsocketsClient&, websockets2_generic::WebsocketsMessage)>::operator bool() const': C:\Arduino\libraries\WebSockets2_Generic-master\src/Tiny_Websockets_Generic/internals/wscrypto/sha1.hpp:73: multiple definition of websockets2_generic::WebsocketsServer::WebsocketsServer()'; C:\Users\CHANYO1\AppData\Local\Temp\arduino_build_4918\sketch\EthernetWebSocketsClient.cpp.o:C:\Arduino\libraries\WebSockets2_Generic-master\src/WebSockets2_Generic_Server.hpp:182: first defined here
c:/users/chanyoung/appdata/local/arduino15/packages/adafruit/tools/arm-none-eabi-gcc/9-2019q4/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\CHANYO~1\AppData\Local\Temp\arduino_build_4918\sketch\SAMD-Ethernet-Client.ino.cpp.o: in function `websockets2_generic::WebsocketsServer::~WebsocketsServer()':

It shows multiple definition.

I change codes in EthernetWebSocketsClient.h, SAMD-Ethernet-Client.ino.

SAMD-Ethernet-Client.ino

#ifndef EWC_H
#define EWC_H
    
#endif

SAMD-Ethernet-Client.ino

#include "defines.h"
#include <WebSockets2_Generic.h>
    
#include "EthernetWebSocketsClient.h"

void setup()
{}
    
void loop()
{}

I just change the location of

#include "defines.h"
#include <WebSockets2_Generic.h>

Then, I succeed to compile and linking.

I want to implement websocket functions in EthernetWebSocketsClient.cpp file. Thus, EthernetWebSocketsClient.h include websocket2_generic library.

How can I include websocket2_generic library in EthernetWebSocketsClient.h file.

Error Compiling for board MKR WiFi 1010

Describe the bug

I am currently trying with this library and other dependent libraries which have been installed as well. The first 2 errors are the following. I really don't know how to fix this...
I didn't define the define.h as you did in the example. Is that very necessary to do this?

Actual behavior

But something wrong happened and I don't know why...

Debug and AT-command log (if applicable)

C:\Users\yil\OneDrive - Software AG\Documents\Arduino\libraries\WebSockets2_Generic\src/Tiny_Websockets_Generic/server.hpp:84:51: error: expected ')' before '' token
WebsocketsServer(network2_generic::TcpServer
server = new WSDefaultTcpServer);
^
C:\Users\yil\OneDrive - Software AG\Documents\Arduino\libraries\WebSockets2_Generic\src/Tiny_Websockets_Generic/server.hpp:100:25: error: 'TcpServer' in namespace 'websockets2_generic::network2_generic' does not name a type
network2_generic::TcpServer* _server;
^~~~~~~~~

Information

Please ensure to specify the following:

  • Arduino IDE version 1.8.19
  • STM32
  • We just wanna open a websocket port using "client" so that the msg sent from server could be obtained.

Additional context

Add any other context about the problem here.

Client IP address availability?

Thanks for a great library

I cant seem to find the following anywhere.

I am using the Teensy41_Server.ino websocket server is it possible to have a method to get the websocket client's IP address please? Or is there any other way to do so?

Eg client.remoteIP() ?

This is useful for IP filtering etc.

Many thanks
Marios

Compile for Arduino Leonardo fails for missing STL

Hi

At first I would to say I'm new to Arduino world, that excuse me in advance if I made a mistake somewhere. Basically I have the Arduino Leonardo board with an ethernet shield with W5500 chip. I would to use your library to exchange data through WebSocket library but, using Visual Studio Code with platformio, I can't compile. The error refer to the include file not found. Googling around I discovered that AVR compiler miss the STL support but after tried to add some alternative package for import STL I still receive errors because you code makes heavy use of the STL library. I tried to read all the tutorial here but I don't understand yet if I miss some steps or is not possible to use the library with Leonardo board.

Can you help me?

Thank you

Connect() is blocking?

Looking at the example code: bool connected = client.connect(websockets_connection_string); it seems to me that connect() will block until the connection is made or fails. Is that correct? Is there any way to perform the connection in the background and use the event callback to detect connection?

Numerous errors logged when compiling, not sure what the actual issue is.

Hi there! Whenever I build my code, I get multiple errors:

Arduino: 1.8.15 (Mac OS X), Board: "Arduino NANO 33 IoT"

In file included from /Users/jackmerrill/Documents/Arduino/libraries/WebSockets2_Generic-master/src/WebSockets2_Generic.h:49:0,
                 from /Users/jackmerrill/Documents/Arduino/Friendship_Lamp/Friendship_Lamp.ino:9:
/Users/jackmerrill/Documents/Arduino/libraries/WebSockets2_Generic-master/src/Tiny_Websockets_Generic/message.hpp:72:4: warning: #warning WEBSOCKETS_USE_ESP_WIFI in message.hpp [-Wcpp]
   #warning WEBSOCKETS_USE_ESP_WIFI in message.hpp
    ^~~~~~~
In file included from /Users/jackmerrill/Documents/Arduino/libraries/WebSockets2_Generic-master/src/WebSockets2_Generic.h:50:0,
                 from /Users/jackmerrill/Documents/Arduino/Friendship_Lamp/Friendship_Lamp.ino:9:
/Users/jackmerrill/Documents/Arduino/libraries/WebSockets2_Generic-master/src/Tiny_Websockets_Generic/client.hpp:78:4: warning: #warning WEBSOCKETS_USE_ESP_WIFI in client.hpp [-Wcpp]
   #warning WEBSOCKETS_USE_ESP_WIFI in client.hpp
    ^~~~~~~
In file included from /Users/jackmerrill/Documents/Arduino/libraries/WebSockets2_Generic-master/src/WebSockets2_Generic.h:51:0,
                 from /Users/jackmerrill/Documents/Arduino/Friendship_Lamp/Friendship_Lamp.ino:9:
/Users/jackmerrill/Documents/Arduino/libraries/WebSockets2_Generic-master/src/Tiny_Websockets_Generic/server.hpp:73:4: warning: #warning WEBSOCKETS_USE_ESP_WIFI in server.hpp [-Wcpp]
   #warning WEBSOCKETS_USE_ESP_WIFI in server.hpp
    ^~~~~~~
/Users/jackmerrill/Documents/Arduino/libraries/WebSockets2_Generic-master/src/Tiny_Websockets_Generic/server.hpp:83:51: error: expected ')' before '*' token
       WebsocketsServer(network2_generic::TcpServer* server = new WSDefaultTcpServer);
                                                   ^
/Users/jackmerrill/Documents/Arduino/libraries/WebSockets2_Generic-master/src/Tiny_Websockets_Generic/server.hpp:99:25: error: 'TcpServer' in namespace 'websockets2_generic::network2_generic' does not name a type
       network2_generic::TcpServer* _server;
                         ^~~~~~~~~
In file included from /Users/jackmerrill/Documents/Arduino/libraries/WebSockets2_Generic-master/src/WebSockets2_Generic.h:54:0,
                 from /Users/jackmerrill/Documents/Arduino/Friendship_Lamp/Friendship_Lamp.ino:9:
/Users/jackmerrill/Documents/Arduino/libraries/WebSockets2_Generic-master/src/WebSockets2_Generic_Client.hpp: In constructor 'websockets2_generic::WebsocketsClient::WebsocketsClient()':
/Users/jackmerrill/Documents/Arduino/libraries/WebSockets2_Generic-master/src/WebSockets2_Generic_Client.hpp:54:76: error: 'WSDefaultTcpClient' was not declared in this scope
   WebsocketsClient::WebsocketsClient() : WebsocketsClient(std::make_shared<WSDefaultTcpClient>())
                                                                            ^~~~~~~~~~~~~~~~~~
/Users/jackmerrill/Documents/Arduino/libraries/WebSockets2_Generic-master/src/WebSockets2_Generic_Client.hpp:54:96: error: no matching function for call to 'make_shared<<expression error> >()'
   WebsocketsClient::WebsocketsClient() : WebsocketsClient(std::make_shared<WSDefaultTcpClient>())
                                                                                                ^
In file included from /Users/jackmerrill/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/c++/7.2.1/memory:81:0,
                 from /Users/jackmerrill/Documents/Arduino/libraries/WebSockets2_Generic-master/src/Tiny_Websockets_Generic/internals/websockets_endpoint.hpp:42,
                 from /Users/jackmerrill/Documents/Arduino/libraries/WebSockets2_Generic-master/src/Tiny_Websockets_Generic/client.hpp:43,
                 from /Users/jackmerrill/Documents/Arduino/libraries/WebSockets2_Generic-master/src/WebSockets2_Generic.h:50,
                 from /Users/jackmerrill/Documents/Arduino/Friendship_Lamp/Friendship_Lamp.ino:9:
/Users/jackmerrill/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/c++/7.2.1/bits/shared_ptr.h:703:5: note: candidate: template<class _Tp, class ... _Args> std::shared_ptr<_Tp> std::make_shared(_Args&& ...)
     make_shared(_Args&&... __args)
     ^~~~~~~~~~~
/Users/jackmerrill/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/c++/7.2.1/bits/shared_ptr.h:703:5: note:   template argument deduction/substitution failed:
In file included from /Users/jackmerrill/Documents/Arduino/libraries/WebSockets2_Generic-master/src/WebSockets2_Generic.h:54:0,
                 from /Users/jackmerrill/Documents/Arduino/Friendship_Lamp/Friendship_Lamp.ino:9:
/Users/jackmerrill/Documents/Arduino/libraries/WebSockets2_Generic-master/src/WebSockets2_Generic_Client.hpp:54:96: error: template argument 1 is invalid
   WebsocketsClient::WebsocketsClient() : WebsocketsClient(std::make_shared<WSDefaultTcpClient>())
                                                                                                ^
In file included from /Users/jackmerrill/Documents/Arduino/libraries/WebSockets2_Generic-master/src/WebSockets2_Generic.h:54:0,
                 from /Users/jackmerrill/Documents/Arduino/Friendship_Lamp/Friendship_Lamp.ino:9:
/Users/jackmerrill/Documents/Arduino/libraries/WebSockets2_Generic-master/src/WebSockets2_Generic_Client.hpp: In member function 'void websockets2_generic::WebsocketsClient::upgradeToSecuredConnection()':
/Users/jackmerrill/Documents/Arduino/libraries/WebSockets2_Generic-master/src/WebSockets2_Generic_Client.hpp:398:23: error: 'WSDefaultSecuredTcpClient' does not name a type
     auto client = new WSDefaultSecuredTcpClient;
                       ^~~~~~~~~~~~~~~~~~~~~~~~~
/Users/jackmerrill/Documents/Arduino/libraries/WebSockets2_Generic-master/src/WebSockets2_Generic_Client.hpp:464:37: error: 'WSDefaultSecuredTcpClient' was not declared in this scope
     this->_client = std::shared_ptr<WSDefaultSecuredTcpClient>(client);
                                     ^~~~~~~~~~~~~~~~~~~~~~~~~
/Users/jackmerrill/Documents/Arduino/libraries/WebSockets2_Generic-master/src/WebSockets2_Generic_Client.hpp:464:62: error: template argument 1 is invalid
     this->_client = std::shared_ptr<WSDefaultSecuredTcpClient>(client);
                                                              ^
In file included from /Users/jackmerrill/Documents/Arduino/libraries/WebSockets2_Generic-master/src/WebSockets2_Generic.h:55:0,
                 from /Users/jackmerrill/Documents/Arduino/Friendship_Lamp/Friendship_Lamp.ino:9:
/Users/jackmerrill/Documents/Arduino/libraries/WebSockets2_Generic-master/src/WebSockets2_Generic_Server.hpp: At global scope:
/Users/jackmerrill/Documents/Arduino/libraries/WebSockets2_Generic-master/src/WebSockets2_Generic_Server.hpp:52:37: error: expected constructor, destructor, or type conversion before '(' token
   WebsocketsServer::WebsocketsServer(network2_generic::TcpServer* server) : _server(server) {}
                                     ^
/Users/jackmerrill/Documents/Arduino/libraries/WebSockets2_Generic-master/src/WebSockets2_Generic_Server.hpp: In member function 'bool websockets2_generic::WebsocketsServer::available()':
/Users/jackmerrill/Documents/Arduino/libraries/WebSockets2_Generic-master/src/WebSockets2_Generic_Server.hpp:56:18: error: 'class websockets2_generic::WebsocketsServer' has no member named '_server'
     return this->_server->available();
                  ^~~~~~~
/Users/jackmerrill/Documents/Arduino/libraries/WebSockets2_Generic-master/src/WebSockets2_Generic_Server.hpp: In member function 'void websockets2_generic::WebsocketsServer::listen(uint16_t)':
/Users/jackmerrill/Documents/Arduino/libraries/WebSockets2_Generic-master/src/WebSockets2_Generic_Server.hpp:61:11: error: 'class websockets2_generic::WebsocketsServer' has no member named '_server'
     this->_server->listen(port);
           ^~~~~~~
/Users/jackmerrill/Documents/Arduino/libraries/WebSockets2_Generic-master/src/WebSockets2_Generic_Server.hpp: In member function 'bool websockets2_generic::WebsocketsServer::poll()':
/Users/jackmerrill/Documents/Arduino/libraries/WebSockets2_Generic-master/src/WebSockets2_Generic_Server.hpp:66:18: error: 'class websockets2_generic::WebsocketsServer' has no member named '_server'
     return this->_server->poll();
                  ^~~~~~~
/Users/jackmerrill/Documents/Arduino/libraries/WebSockets2_Generic-master/src/WebSockets2_Generic_Server.hpp: In member function 'websockets2_generic::WebsocketsClient websockets2_generic::WebsocketsServer::accept()':
/Users/jackmerrill/Documents/Arduino/libraries/WebSockets2_Generic-master/src/WebSockets2_Generic_Server.hpp:123:60: error: '_server' was not declared in this scope
     std::shared_ptr<network2_generic::TcpClient> tcpClient(_server->accept());
                                                            ^~~~~~~
/Users/jackmerrill/Documents/Arduino/libraries/WebSockets2_Generic-master/src/WebSockets2_Generic_Server.hpp: In destructor 'virtual websockets2_generic::WebsocketsServer::~WebsocketsServer()':
/Users/jackmerrill/Documents/Arduino/libraries/WebSockets2_Generic-master/src/WebSockets2_Generic_Server.hpp:193:11: error: 'class websockets2_generic::WebsocketsServer' has no member named '_server'
     this->_server->close();
           ^~~~~~~
exit status 1
Error compiling for board Arduino NANO 33 IoT.


This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

I'm a bit of an Arduino noob so I'm not exactly sure how to fix this (yes my project is a bit ambitious, but I can pull it off).

Here's my project's code repository: https://github.com/jackmerrill/FriendshipLamp

I copied some code from the Generic WifiNINA SAMD project, https://github.com/khoih-prog/WebSockets2_Generic/tree/master/examples/Generic/WiFiNINA/SAMD/SAMD-Client

the EasyWifi is another repository that I slightly modified in an attempt to get it working with WiFiNINA_Generic.

Any and all help is appreciated, thank you!

QNEthernet and NativeEthernet staticIP not working with WS Server

The original issue was reported in PJRC forum in WebSockets_Generic Library

Duplicated here for easier to follow-up.

  1. DHCP is working OK with QNEthernet
Starting Teensy41_Client on TEENSY 4.1 using QNEthernet
WebSockets2_Generic v1.10.1
=========== USE_QN_ETHERNET ===========
Initialize Ethernet using DHCP => Connected! IP address:192.168.2.107
[WS] WebsocketsClient::doestStartsWith: str = ws://192.168.2.30:8080
[WS] WebsocketsClient::doestStartsWith: prefix = ws://
[WS] WebsocketsClient::connect: step 1
[WS] WebsocketsClient::generateHandshake: base64Authorization = 
[WS] WebsocketsClient::generateHandshake: handshake = GET / HTTP/1.1
Host: 192.168.2.30
Sec-WebSocket-Key: MDEyMzQ1Njc4OWFiY2RlZg==
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Version: 13
User-Agent: TinyWebsockets Client
Authorization: Basic 
Origin: https://github.com/khoih-prog/Websockets2_Generic

[WS] WebsocketsClient::connect: base64Authorization = 
[WS] WebsocketsClient::connect: step 2
[WS] WebsocketsClient::connect: step 3
[WS] WebsocketsClient::connect: step 4
[WS] WebsocketsClient::doestStartsWith: str = HTTP/1.1 101 Switching Protocols

[WS] WebsocketsClient::doestStartsWith: prefix = HTTP/1.1 101
[WS] WebsocketsClient::connect: step 5
[WS] WebsocketsClient::connect: step 6
[WS] WebsocketsClient::generateHandshake: key = Upgrade
[WS] WebsocketsClient::generateHandshake: value = websocket
[WS] WebsocketsClient::generateHandshake: key = Connection
[WS] WebsocketsClient::generateHandshake: value = Upgrade
[WS] WebsocketsClient::generateHandshake: key = Sec-WebSocket-Accept
[WS] WebsocketsClient::generateHandshake: value = BACScCJPNqyz+UBoqMH89VmURoA=
[WS] WebsocketsClient::generateHandshake: key = Origin
[WS] WebsocketsClient::generateHandshake: value = https://github.com/khoih-prog/Websockets2_Generic
[WS] WebsocketsClient::connect: step 7
Connected to server : ws://192.168.2.30:8080
Got Message: Hello Server
  1. Static IP is not working OK with QNEthernet
Starting Teensy41_Client on TEENSY 4.1 using QNEthernet
WebSockets2_Generic v1.10.1
=========== USE_QN_ETHERNET ===========
Initialize Ethernet using static IP => Connected! IP address:192.168.2.222
[WS] WebsocketsClient::doestStartsWith: str = ws://192.168.2.30:8080
[WS] WebsocketsClient::doestStartsWith: prefix = ws://
[WS] WebsocketsClient::connect: step 1
[WS] WebsocketsClient::connect: not _connectionOpen, host = 192.168.2.30 , port = 8080
Couldn't connect to server : ws://192.168.2.30:8080

Multiple Clients Teensy41 server example QNEthernet

HI,
When trying to run the following example, my teensy seems to get stuck in a loop of accepting new websocket client connections. I don't quite understand what is happening. I'm using the latest build of QNEthernet. Doesn't seem to happen with Native Ethernet.
Possibly didn't happen on versions prior to latest release?

https://github.com/khoih-prog/WebSockets2_Generic/blob/master/examples/Generic/Teensy41_QNEthernet/MultipleClients_Teensy41_Server/MultipleClients_Teensy41_Server.ino

Terminal output is

Accepted new websockets client at index 0
Accepted new websockets client at index 0
Accepted new websockets client at index 0
Accepted new websockets client at index 0
Accepted new websockets client at index 0
Accepted new websockets client at index 0
...

Arduino IDE version: 1.8.19
Teensy4.1
QNEthernet 0.17.0
Windows 10

Many thanks
Richard.

RP2040W-Server example does not compile without errors

Arduino IDE version: 2.0.2
Raspberry Pi Pico/RP2040 by Earle F. Philhower III Version: 2.6.4
WebSockets2_Generic by Gil Maimon, Khoi Hoang Version: 1.13.1
Raspberry Pi Pico W
OS: Windows 10

Describe the bug

RP2040W-Server example does not compile without many warnings.

Steps to Reproduce

Open RP2040W-Server example, select Raspberry Pi Pico W as board type and try to "Verify" the sketch

Expected behavior

Example comiles without any warnings.

Actual behavior

Severale compiler warnings occur.

Debug and AT-command log (if applicable)

In file included from c:\Users\Stefan.Riese\Documents\Arduino\libraries\WebSockets2_Generic\src/WebSockets2_Generic.h:49, from C:\Users\Stefan.Riese\AppData\Local\Temp\.arduinoIDE-unsaved2022115-14312-1awp9ql.a9d\RP2040W-Server\RP2040W-Server.ino:43: c:\Users\Stefan.Riese\Documents\Arduino\libraries\WebSockets2_Generic\src/Tiny_Websockets_Generic/message.hpp:78:4: warning: #warning WEBSOCKETS_USE_RP2040W in message.hpp [-Wcpp] 78 | #warning WEBSOCKETS_USE_RP2040W in message.hpp | ^~~~~~~ In file included from c:\Users\Stefan.Riese\Documents\Arduino\libraries\WebSockets2_Generic\src/Tiny_Websockets_Generic/message.hpp:79, from c:\Users\Stefan.Riese\Documents\Arduino\libraries\WebSockets2_Generic\src/WebSockets2_Generic.h:49, from C:\Users\Stefan.Riese\AppData\Local\Temp\.arduinoIDE-unsaved2022115-14312-1awp9ql.a9d\RP2040W-Server\RP2040W-Server.ino:43: c:\Users\Stefan.Riese\Documents\Arduino\libraries\WebSockets2_Generic\src/Tiny_Websockets_Generic/internals/ws_common_RP2040W.hpp:55:4: warning: #warning Using RP2040W CYC43439 WIFI in ws_common_RP2040W.hpp [-Wcpp] 55 | #warning Using RP2040W CYC43439 WIFI in ws_common_RP2040W.hpp | ^~~~~~~ c:\Users\Stefan.Riese\Documents\Arduino\libraries\WebSockets2_Generic\src/Tiny_Websockets_Generic/internals/ws_common_RP2040W.hpp:63:6: warning: #warning Using CYC43439 WIFI for RP2040W in ws_common_RP2040W.hpp [-Wcpp] 63 | #warning Using CYC43439 WIFI for RP2040W in ws_common_RP2040W.hpp | ^~~~~~~ In file included from c:\Users\Stefan.Riese\Documents\Arduino\libraries\WebSockets2_Generic\src/WebSockets2_Generic.h:50, from C:\Users\Stefan.Riese\AppData\Local\Temp\.arduinoIDE-unsaved2022115-14312-1awp9ql.a9d\RP2040W-Server\RP2040W-Server.ino:43: c:\Users\Stefan.Riese\Documents\Arduino\libraries\WebSockets2_Generic\src/Tiny_Websockets_Generic/client.hpp:86:4: warning: #warning WEBSOCKETS_USE_RP2040W in client.hpp [-Wcpp] 86 | #warning WEBSOCKETS_USE_RP2040W in client.hpp | ^~~~~~~ In file included from c:\Users\Stefan.Riese\Documents\Arduino\libraries\WebSockets2_Generic\src/WebSockets2_Generic.h:51, from C:\Users\Stefan.Riese\AppData\Local\Temp\.arduinoIDE-unsaved2022115-14312-1awp9ql.a9d\RP2040W-Server\RP2040W-Server.ino:43: c:\Users\Stefan.Riese\Documents\Arduino\libraries\WebSockets2_Generic\src/Tiny_Websockets_Generic/server.hpp:79:4: warning: #warning WEBSOCKETS_USE_RP2040W in server.hpp [-Wcpp] 79 | #warning WEBSOCKETS_USE_RP2040W in server.hpp | ^~~~~~~ Sketch uses 347068 bytes (16%) of program storage space. Maximum is 2093056 bytes. Global variables use 68204 bytes (26%) of dynamic memory, leaving 193940 bytes for local variables. Maximum is 262144 bytes.

Screenshots

N/A

Information

Socket.io client on Teensy Native Ethernet not working

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

MKR1000 and socket.io

Hello,

Can your library be used to communicate with a websocket server created with nodejs + express + socket.io?
Can it simultaneously be used to call a rest api made with nodejs + express?
Do you have examples using rest api?
Can it be used with a MKR1000 and Wifi101?
Do you have examples using Wifi101?

Thank you very much for all your information.

Regards,

Multiple definition errors due to non-standard naming convention

Hello,
First of all, thank you for your work on this very useful library.
As several people have already pointed out in #3 and #15, using WebSockets2_Generic in a project that consists of multiple source files can lead to "multiple definition" errors while linking. The reason for this is that most of the code in this library is inside .hpp files which are #include-ed. This is not standard practice - in C++ source code should be in .cpp files which do not get #include-ed but instead are linked together after compilation by the linker.
Do you have a good reason to break such a fundamental C++ convention? If not, can you please rename your source files to *.cpp to prevent linking errors? This is the only issue that stops me from recommending this library as the best websocket library for embedded projects.

Loop function hangs even without the poll function

Hi it's me again haha. When I run my code on the board, it only seems to run the loop function once, but if I remove / comment out any of the Websocket code, it works completely fine (lines 162 and 194).

Code: https://github.com/jackmerrill/FriendshipLamp/blob/main/Friendship_Lamp.ino

Here's how I know it doesn't loop:

23:11:39.759 -> Connnection Opened
23:11:39.759 -> Connected!
23:11:39.759 -> available
23:11:39.759 -> on
23:11:39.759 -> number of button pushes: 1
23:11:39.759 -> color

available and beyond should be printing more than just once.

Any and all help is appreciated, thanks!

Examples Generic WiFiNINA RP2040 ServerAllFunctionsDemo does not work

Describe the bug

This sample is non functional: https://github.com/khoih-prog/WebSockets2_Generic/tree/master/examples/Generic/WiFiNINA/RP2040/RP2040_ServerAllFunctionsDemo

Steps to Reproduce

Using an Arudino Nano RP2040 Connect, upload the noted example.

Expected behavior

The RGB sliders would actually work, changing the onboard LED colors.
Sending data to the hosted socket would also display the data received.

Actual behavior

The RGB sliders do not do anything. The onboard LED remains off.
When sending data to the hosted socket, the board acknowledges that a message has been received, however zero data is displayed, even when sending data to it.

Information

Arduino IDE version: 2.0.3
Arduino Mbed OS RP2040 3.5.1
NANO RP2040 CONNECT

VSCode + PIO for Teensy4.1 compilation error. Complaining stm32_eth.h missing!

Setup and Target information:

  • Visual Studio Code
  • PlatformIO Core, version 5.0.4
  • Teensy4.1 (so STM32) with built in ethernet ()
  • Operating system macOS 10.14.6

Note: The library was installed using platformio's library manager

Simplest platformio.ini file content:

[env:teensy41]
platform = teensy
board = teensy41
framework = arduino
lib_deps = khoih-prog/WebSockets2_Generic@^1.8.1

Simplest main.cpp content:

#include <Arduino.h>

void setup()
{
  // put your setup code here, to run once:
}

void loop()
{
  // put your main code here, to run repeatedly:
}

The problem:

Screenshot 2021-10-15 at 4 13 26 PM

While trying to compile against Teensy4.1 with built in Ethernet, it not compiling but throwing errors complaining that:

  1. In <proj_dir>/.pi/libdeps/teensy41/STM32Ethernet/src/utility/stm32_eth.h, the reference stm32_def.h can not be located. Screenshot 2021-10-15 at 4 32 59 PM

  2. And that in <proj_dir>/.pio/build/teensy41/lib24a/STM32Ethernet/utility/, the stm32_eth.cpp is also missing.

Don't know what's happening ๐Ÿ˜ถ
I guessing no need to use any patch files like in case of Arduino IDE installation, mentioned in the README?
(That's one reason for me to choose PIO in VS code over Arduino IDE)

Any pointers?

multiple definition of `websockets2_generic::WebsocketsServer::....'

Hello,

Firstly thanks for the work you've put into the library.

I'm using ver 1.1 of your library in conjunction with Sloeber on Eclipse on a 8266.

I have an issue which seems related to a closed bug report (#3) but I haven't been able to solve it with your proposed solution.

I have the following setup:

sensor.ino


#include "LwDevice.h"
#include <Arduino.h>

lwDevice lwNode;

setup()

loop()

lwDevice.cpp


#include "LwDevice.h"
#include <Arduino.h>

using namespace std;

namespace lw {

int LwDevice::sendSocketJSON(){

//websockets2_generic::WebsocketsClient socket; Compiles ok if initialised here
do socket stuff...

}
}

lwDevice.h

#include <WebSockets2_Generic.h>

namespace lw {

class LwDevice {
private:
websockets2_generic::WebsocketsClient socket; // lots of multiple def errors when init here

}
}

So when creating the object inside the sendSocketJSON() it compiles correctly, moving it to the class causes multiple definition errors.
E.g:
/opt/eclipse/arduinoPlugin/packages/esp8266/hardware/esp8266/2.7.0/libraries/EEPROM/EEPROM.cpp:108: multiple definition of EEPROMClass::write(int, unsigned char)'; ./libraries/ESP_EEPROM/src/ESP_EEPROM.cpp.o:/opt/eclipse/arduinoPlugin/libraries/ESP_EEPROM/2.1.1/src/ESP_EEPROM.cpp:296: first defined here /opt/eclipse/arduinoPlugin/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-4-b40a506/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: ./libraries/EEPROM/EEPROM.cpp.o: in function EEPROMClass::commit()':
/opt/eclipse/arduinoPlugin/packages/esp8266/hardware/esp8266/2.7.0/libraries/EEPROM/EEPROM.cpp:127: multiple definition of EEPROMClass::commit()'; ./libraries/ESP_EEPROM/src/ESP_EEPROM.cpp.o:/opt/eclipse/arduinoPlugin/libraries/ESP_EEPROM/2.1.1/src/ESP_EEPROM.cpp:339: first defined here /opt/eclipse/arduinoPlugin/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-4-b40a506/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: ./libraries/EEPROM/EEPROM.cpp.o: in function EEPROMClass::end()':
/opt/eclipse/arduinoPlugin/packages/esp8266/hardware/esp8266/2.7.0/libraries/EEPROM/EEPROM.cpp:81: multiple definition of EEPROMClass::end()'; ./libraries/ESP_EEPROM/src/ESP_EEPROM.cpp.o:/opt/eclipse/arduinoPlugin/libraries/ESP_EEPROM/2.1.1/src/ESP_EEPROM.cpp:248: first defined here /opt/eclipse/arduinoPlugin/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-4-b40a506/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: ./libraries/EEPROM/EEPROM.cpp.o:/opt/eclipse/arduinoPlugin/packages/esp8266/hardware/esp8266/2.7.0/libraries/EEPROM/EEPROM.cpp:156: multiple definition of EEPROM'; ./libraries/ESP_EEPROM/src/ESP_EEPROM.cpp.o:/opt/eclipse/arduinoPlugin/libraries/ESP_EEPROM/2.1.1/src/ESP_EEPROM.cpp:528: first defined here

Any pointers would be gratefully appreciated,

Error 1006

I'm Using ESP8266-Client.ino Example and connected to this site : https://socketsbay.com/test-websockets
i change
in defines.h
const char* websockets_server_host = "socketsbay.com"; //Enter server address
#define WEBSOCKETS_PORT 443 //8080

and in io file
bool connected = client.connectSecure(websockets_server_host, websockets_server_port, "/wss/v2/2/demo/");

it's work fine
but after 50 second the connection is close with code 1006

can you test and check why the connection close with code 1006

Thank you

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.