khoih-prog / WebSockets2_Generic

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
GNU General Public License v3.0
81 stars 30 forks source link

Multiple Clients Teensy41 server example QNEthernet #65

Closed videojedi closed 1 year ago

videojedi commented 1 year ago

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.

khoih-prog commented 1 year ago

Hi @videojedi

Just comment out the unnecessary line

https://github.com/khoih-prog/WebSockets2_Generic/blob/3dd5c9f98470b1a0e445c62a3535934e83aec72d/examples/Generic/Teensy41_QNEthernet/MultipleClients_Teensy41_Server/MultipleClients_Teensy41_Server.ino#L253

Be sure to have the client connect to the same IP:port

Tested OK for

QNEthernet v0.14.0

Starting MultiClients_Teensy41_Server on TEENSY 4.1 using QNEthernet
WebSockets2_Generic v1.13.2
=========== USE_QN_ETHERNET ===========
Initialize Ethernet using DHCP => IP Address = 192.168.2.119
Server available at ws://192.168.2.119:8080
Got Message: Hello to Server from ESP32
Connection closed
Got Message: Hello to Server from ESP32
Connection closed
Got Message: Hello to Server from ESP32
Connection closed
Got Message: Hello to Server from ESP32

QNEthernet v0.17.0

Starting MultiClients_Teensy41_Server on TEENSY 4.1 using QNEthernet
WebSockets2_Generic v1.13.2
=========== USE_QN_ETHERNET ===========
Initialize Ethernet using DHCP => IP Address = 192.168.2.119
Server available at ws://192.168.2.119:8080
Got Message: Hello to Server from ESP32
Connection closed
Got Message: Hello to Server from ESP32