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
83 stars 30 forks source link

Running Http and Websocket Servers concurrently #1

Closed khoih-prog closed 4 years ago

khoih-prog commented 4 years ago

@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.

khoih-prog commented 4 years ago

Hi @jakespeed1311

The new Version v1.0.6 has been released with these new features to fix the blocking action of WebSockets Server that prevents the concurrent running of WebServer and WebSockets Server you experienced so far.

New in v1.0.6

  1. Add non-blocking WebSockets Server feature to enable WS Server and WebServer running concurently. See Support as Http server and the Websockets server on Arduino DUE and Running Http and Websocket Servers concurrently. Thanks to bug report and persistence of Jake.
  2. Add non-blocking WebSockets Server and WebServer examples.
  3. Add Ethernet Library Patches
  4. Add Arduino SAMD Packages_Patches to fix compiler errors when using Standard Template Library STL

Please try the example SAMDUE-Ethernet_AdvancedWebServer to have feelings. Then modify it to fix your purpose.

Please be noted that your bug report and persistence, resulting in the new Version v1.0.6, has been noted in Contributions-and-Thanks