Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info

        const char* headerNames[] = { "Location", "Last-Modified" };
        http.collectHeaders(headerNames, sizeof(headerNames) / sizeof(headerNames[0]));

        int rc = http.GET();
        String location = http.header("Location");
        Serial.println("location ");

        //   http.addHeader("Accept", "text/event-stream");
        //   http.addHeader("Cache-Control", "no-cache");

        Serial.println("CAME FROM 307! ");
        httpCode = http.GET();

        if (httpCode == HTTP_CODE_OK) {
          Serial.println("CANT ENTER HRE ");

          // get lenght of document (is -1 when Server sends no Content-Length header)
          int len = http.getSize();
When i go to new location (with a browser page it i see my data) but i cant go on with esp side : Serial.println("CANT ENTER HRE ");
OK At last esp has live connection
http.begin(location,"9A E1 A3 B7 88 E0 C9 A3 3F 13 72 4E B5 CB C7 27 41 B2 0F 6A");

@Links2004 I cant reach loop when its streaming. Is there a trick?

   // read all data from server
          while (http.connected() && (len > 0 || len == -1)) {
            // get available data size
            size_t size = stream->available();

            if (size) {
              // read up to 128 byte
              int c = stream->readBytes(buff, ((size > sizeof(buff)) ? sizeof(buff) : size));

              // write it to Serial
              USE_SERIAL.write(buff, c);

              if (len > 0) {
                len -= c;

Do i have to put all loop functions inside while(... function?

you are not forced too, when you save the http and stream variable globally its possible to handle it in the loop.
but it easyer that way.
may simply put your code in a function and call it in the while and in the loop.
i cant send integers/float to client
websocket.sendTXT(num, payload);
Hey there! Somebody here?
hi guys
I am trying to use websockets slibrary within esp32 arduino environment
I am building in platformio
and I get:
C:\Users\klemen\Documents\Arduino\libraries\arduinoWebSockets\src\WebSockets.cpp:42:18: fatal error: Hash.h: No such file or directory
And there is no Hash.h in espressif-esp32 folder...
This person's solution might work for you
Hi there! I have difficulties setting up websockets on my Arduino UNO WiFi. Does this lib even support this board?
@bzub I fixed I'd extra hash library was missing
Mehrdad K
hi @Links2004 , I installed the Nginx and intend to used async WebSocketsClient to check periodically availability information on server , do you know any links or temple code for such purpose ?
Nginx is only a webserver It can phase through (WebSocket Proxy) a ws connection to a WS server, but you need a ws server Application first.
may: https://www.nginx.com/blog/realtime-applications-nginx/
helps you, I typical have a nodejs ws server running where my ESPs connect too.
very basic server:
Albert Møller Nielsen
Hey guys :)
Leder Diez

In file included from C:\Users\leder\Documents\Arduino\libraries\WebSockets\src/WebSocketsClient.h:28:0,

             from C:\Users\leder\Documents\Arduino\libraries\WebSockets\examples\avr\WebSocketClientAVR\WebSocketClientAVR.ino:13:

C:\Users\leder\Documents\Arduino\libraries\WebSockets\src/WebSockets.h:35:22: fatal error: functional: No such file or directory

include <functional>

Miguel Bustamante
hi guys

Hi there! Thank you for time and your effort.
I have a general question (newbie) about arduinoWebSockets and ESPAsyncWebServer. I'm using ESP 8266 or ESP 32 modules, and as far as I understand both of them are supported in both libraries.

So my aim is to have a website for controlling the ESP and showing the status and some information on a website. Which is stored as .html or .css in Flash with SPIFFS (which can be done with the SPIFFSEditor.h library , am I wrong?
The provided examples of both library work (one already uses SPIFFS).

I would appreciate if someone could perhaps outline the differences / pro /contra or your opinion about the two libraries, please?

Clemens Kirchgatterer
@TKaluza ESPAsyncWebServer is generally faster (or more snappy so to speak) but needs more care to be taken, because requests run asynchronously to loop(). it needs more RAM as well, which is especially important on ESP8266. on the plus side it has the websockets implementation integrated and does not need an additional socket to listen on (bind to). which might be important or not, depending on your usecase. this is from the top of my head. to be consumed with the usual grain of salt.
@everslick Thank you very much for this Information, it is very appreciated!!
Clemens Kirchgatterer

Hi, I'm trying to establish a websocket connection to a server which supports the following ciphers


Is it possible to do this using the ESP8266? An help would be much appreciated, so far I always get a Error: SSL error 40.

den har
Hi anyone here manage to get websockets client and server working in same esp8266 ? deperately need some help
Bhupesh Varshney
Hey can anyone help me connecting my socketio node server to ESP8266 ??
I am like stuck for weeks now :(

hello everyone I have a question regarding https://github.com/Links2004/arduinoWebSockets/blob/master/examples/esp8266/WebSocketClientStomp/WebSocketClientStomp.ino

I managed to establish connection to my spring /ws and it says
[WSc] Connected to url: /ws
but whenever I publish json to /topic or /queue on that websocket there is no response in WebSocketClientStomp.ino
I suppose it should be handled by this case branch?
case WStype_TEXT: ...
Did anyone had similar usecase?

hi room
playing around with the websocket library with my nodeMCU. I got it to work on my local network, but Im having trouble getting it to work on my https server
hi guys, my websocket connection with repetier-server randomly crashes. I have a arduino program working with websockets, ,mqtt and ArduinoJson. Can anybody look at my debug output?
after a few pings it hangs...:
16:11:51.797 -> [WS][0][sendFrame] ------- send message frame -------
16:11:51.797 -> [WS][0][sendFrame] fin: 1 opCode: 1 mask: 1 length: 75 headerToPayload: 0
16:11:51.832 -> [WS][0][sendFrame] text: {"action":"ping","data":{},"printer":"Anycubic_i3_MegaS","callback_id":305}
16:11:51.832 -> [WS][0][sendFrame] pack to one TCP package...
16:11:51.832 -> [write] n: 81 t: 34787
16:11:51.832 -> [WS][0][sendFrame] sending Frame Done (4315us).
16:11:51.832 -> RSB: ping sent: {"action":"ping","data":{},"printer":"Anycubic_i3_MegaS","callback_id":305}
16:11:58.879 -> [WS][0][handleWebsocketWaitFor] size: 2 cWsRXsize: 0
16:11:58.879 -> [readCb] n: 2 t: 41835
16:11:58.879 -> [WS][0][handleWebsocketWaitFor][readCb] size: 2 ok: 1
16:11:58.879 -> [WS][0][handleWebsocket] ------- read massage frame -------
16:11:58.879 -> [WS][0][handleWebsocket] fin: 1 rsv1: 0 rsv2: 0 rsv3 0 opCode: 1
16:11:58.915 -> [WS][0][handleWebsocket] mask: 0 payloadLen: 74
16:11:58.915 -> [readCb] n: 74 t: 41859
16:11:58.915 -> [WS][0][handleWebsocket] text: {"callback_id":-1,"data":[{"data":{},"event":"timer30"}],"eventList":true}
16:11:58.915 -> Free Heap 22096
16:11:58.915 ->
MQ: Publish at topic: universalSmartHomeHub/DATA/repetierServerBridge
16:11:58.948 -> *MQ: Publish message: {"data":{},"event":"timer30"}
16:12:05.964 -> [WS-Client] connection lost.
16:12:05.964 -> [WS-Client] client disconnected.
If server unavailable or server is down, check few hours cause the websocketClient stuck in loop.
When disconnect wifi or reset esp8266 everything is OK.
How we can exit from websocket.loop() in specific time and goto next line main loop? For example 10 second if websocket not connect. Current time out not work Properly with that condition.
Thanks in advance
Hi. I read several discussions of issues of other websocket clients. In one of them it was described that a 10s delay after websockets loop solved most stability problems at esp8266 boards.
I did the same and everything works stable now. I think I should open an issue. The delay should be added to all examples - commented out to my mind
Hi All, anybody got a good reference for ping-pong example. my project is shutting down on code 1006 undefined, suspect it is not staying alive. Is WStype_PING
& WStype_PONG supported in this library?
Hi! Just a very noob question, if you can bear with me. How do I allow ws debug messages? Is there a flag / define? I want to see the messages from the source code files, ie WebsocketsClient.cpp line 647 (not the example ino USE_SERIAL.printf... etc). I already have set Serial.setDebugOutput(true);I have some sort of random hang with the ws connection. It may be something already described. But I cannot add delays in the main loop. I employ the ws in a ~100messages /per second frequency. After a while it stops sending data. I'm trying to find the reason and adjust whatever I can. Thank you.
Christopher Verdegan
How to use PONG with Twitch? I see PING but no Pong, my ESP32 is diconnecting from the twitch chat intermittently
hi, i just wanted to ask if u have time to help me, i am working on make some copy of discord to esp32(just for fun) and i needed to use some websocket for esp32(to generate login qr code) i have the code in python, now i just need to port it to arduino ide, but my issue is that i cant get your library to connect to wss url, if u will have time can u help me?
i can connect to test wss (webSocket.beginSSL("websocket-echo.glitch.me", 443);) with no problem, but i need to connect to discord wss with needs some headers, and idk where i can add them
Does Arduino UNO WiFi rev2 only runs at under 2.0 Release?