Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Websocket Secure crashes when connection to webserver is opened #887

Open
pam-param-pam opened this issue Jun 25, 2024 · 0 comments
Open

Comments

@pam-param-pam
Copy link

pam-param-pam commented Jun 25, 2024

Im using esp8288 nodemcu 12E v3

code bellow:

ESP8266WebServer server(80);
WebsocketsClient wsClient;

//other un important stuff

void loop() {

    switch (state) {
        case STATE_CONNECTING_TO_RELAY: {

            unsigned long wsLoopStartTime = millis();
            wsElapsedTime = wsLoopStartTime - wsStartTime;
            
            if ((wsElapsedTime >= 5000)) { //once every 5 seconds
              
              bool connected = wsClient.connectSecure("host", 443, "path");
              if(connected) {
                Serial.println("Connecetd to relay server!");
                changeState(STATE_RELAY_RUNNING);
              } else {
                  Serial.println("Not Connected!")
              }
              wsClient.onMessage([&](WebsocketsMessage message) {
                Serial.print("Got Message: ");
                Serial.println(message.data());
              });
              wsStartTime = wsLoopStartTime;
            }
           
            break;
        }
 
        case STATE_RELAY_RUNNING: {
            unsigned long wscLoopStartTime = millis();
            wscElapsedTime = wscLoopStartTime - wscStartTime;
            
            if ((wscElapsedTime >= 1000)) { //once every1 second
              if(wsClient.available()) {
              wsClient.poll();
            }
              wscStartTime = wscLoopStartTime;
            }
            
            break;
        }
    }
    server.handleClient();
    delay(100);
}

When websocket is succesfully connected, and i try to connect to AP Point the esp8266 crashes with:

Exception 29: StoreProhibited: A store referenced a page mapped with an attribute that does not permit stores
PC: 0x4000df64
EXCVADDR: 0x00000000

Decoding stack results
0x401000ab: app_entry_redefinable() at C:\Users\jedrz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\core_esp8266_main.cpp:386
0x4023afe7: br_range_dec32be at src\inner.h:614
0x4022a758: br_sha2small_round at src/hash\sha2small.c:86
0x401002d4:  is in ets_post(uint8, ETSSignal, ETSParam) (C:\Users\jedrz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\core_esp8266_main.cpp:238).
0x401002d4:  is in ets_post(uint8, ETSSignal, ETSParam) (C:\Users\jedrz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\core_esp8266_main.cpp:238).
0x40206eaa: WiFiClient::available() at C:\Users\jedrz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\libraries\ESP8266WiFi\src\WiFiClient.cpp:254
0x402126ec:  is in BearSSL::WiFiClientSecureCtx::_run_until(unsigned int, bool) (C:\Users\jedrz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\libraries\ESP8266WiFi\src\WiFiClientSecureBearSSL.cpp:599).
0x40212b8c:  is in BearSSL::WiFiClientSecureCtx::read(unsigned char*, unsigned int) (C:\Users\jedrz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\libraries\ESP8266WiFi\src\WiFiClientSecureBearSSL.cpp:383).
0x40212a2f: BearSSL::WiFiClientSecureCtx::_pollRecvBuffer() at C:\Users\jedrz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\libraries\ESP8266WiFi\src\WiFiClientSecureBearSSL.cpp:427
0x40211dbc: BearSSL::WiFiClientSecureCtx::_engineConnected() at C:\Users\jedrz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\libraries\ESP8266WiFi\src\WiFiClientSecureBearSSL.cpp:260
0x40209690: websockets::network::GenericEspTcpClient<BearSSL::WiFiClientSecure>::available() at c:\Users\jedrz\OneDrive\Dokumenty\Arduino\libraries\ArduinoWebsockets\src/tiny_websockets/network/generic_esp\generic_esp_clients.hpp:28
0x4020afbc:  is in websockets::internals::readData[abi:cxx11](websockets::network::TcpClient&, unsigned long long) (c:\Users\jedrz\OneDrive\Dokumenty\Arduino\libraries\ArduinoWebsockets\src\websockets_endpoint.cpp:177).
0x401008fe:  is in umm_free_core(umm_heap_context_t*, void*) (C:\Users\jedrz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\umm_malloc\umm_malloc.cpp:642).
0x40100eb2:  is in realloc(void*, size_t) (C:\Users\jedrz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\umm_malloc\umm_malloc.cpp:1248).
0x40100c80: malloc(size_t) at C:\Users\jedrz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\umm_malloc\umm_malloc.cpp:912
0x4021e811: mem_malloc at core\mem.c:210
0x4021eed2: pbuf_alloc_LWIP2 at core\pbuf.c:284
0x4020f90c: __esp_suspend() at C:\Users\jedrz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\core_esp8266_features.h:64
0x4020fa5d:  is in __esp_delay(unsigned long) (C:\Users\jedrz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\core_esp8266_main.cpp:161).
0x4020fad2:  is in esp_try_delay(unsigned int, unsigned int, unsigned int) (C:\Users\jedrz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\core_esp8266_main.cpp:182).
0x40207378:  is in ClientContext::_write_from_source(char const*, unsigned int) (C:\Users\jedrz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/coredecls.h:69).
0x4020e448:  is in Stream::SendGenericPeekBuffer(Print*, int, int, unsigned int) (C:\Users\jedrz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/Print.h:63).
0x401008fe:  is in umm_free_core(umm_heap_context_t*, void*) (C:\Users\jedrz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\umm_malloc\umm_malloc.cpp:642).
0x4020e99d:  is in String::operator=(char const*) (C:\Users\jedrz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\WString.cpp:319).
0x40203168:  is in esp8266webserver::ESP8266WebServerTemplate<WiFiServer>::send(int, char const*, Stream*, unsigned int) (C:\Users\jedrz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/Stream.h:64).
0x4020e6f7:  is in String::changeBuffer(unsigned int) (C:\Users\jedrz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/WString.h:328).
0x402031fb:  is in esp8266webserver::ESP8266WebServerTemplate<WiFiServer>::send(int, char const*, String const&) (C:\Users\jedrz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/WString.h:115).
0x4020e78b:  is in String::reserve(unsigned int) (C:\Users\jedrz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\WString.cpp:192).
0x4020ea01:  is in String::String(int, unsigned char) (C:\Users\jedrz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\WString.cpp:53).
0x40203efe: handleRoot() at C:\Users\jedrz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\WString.h:115
0x40212a2f: BearSSL::WiFiClientSecureCtx::_pollRecvBuffer() at C:\Users\jedrz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\libraries\ESP8266WiFi\src\WiFiClientSecureBearSSL.cpp:427
0x402019c5:  is in esp8266webserver::FunctionRequestHandler<WiFiServer>::handle(esp8266webserver::ESP8266WebServerTemplate<WiFiServer>&, HTTPMethod, String const&) (C:\Users\jedrz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\libraries\ESP8266WebServer\src/detail/RequestHandlersImpl.h:62).
0x40203248: esp8266webserver::ESP8266WebServerTemplate<WiFiServer>::_handleRequest() at c:\users\jedrz\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\bits\std_function.h:498
0x40207a20: WiFiServer::accept() at C:\Users\jedrz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\libraries\ESP8266WiFi\src\WiFiServer.cpp:147
0x402046ee: esp8266webserver::ESP8266WebServerTemplate<WiFiServer>::handleClient() at C:\Users\jedrz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\libraries\ESP8266WebServer\src\ESP8266WebServer-impl.h:282
0x40206760: ESP8266WiFiSTAClass::status() at C:\Users\jedrz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\libraries\ESP8266WiFi\src\ESP8266WiFiSTA.cpp:558
0x40204c3f: loop() at C:\Users\jedrz\OneDrive\Dokumenty\Arduino\ATEM_tally_light\ATEM_tally_light.cpp:376
0x402133b8:  is in std::_Function_handler<void(websockets::WebsocketsMessage), loop()::<lambda(websockets::WebsocketsMessage)> >::_M_manager(std::_Any_data &, const std::_Any_data &, std::_Manager_operation) (c:\users\jedrz\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\bits/std_function.h:268).
0x40201120:  is in std::_Function_handler<void(websockets::WebsocketsMessage), loop()::<lambda(websockets::WebsocketsMessage)> >::_M_invoke(const std::_Any_data &, websockets::WebsocketsMessage &&) (c:\users\jedrz\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\bits/invoke.h:103).
0x4020fa99:  is in esp_try_delay(unsigned int, unsigned int, unsigned int) (C:\Users\jedrz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\core_esp8266_main.cpp:169).
0x402046ee: esp8266webserver::ESP8266WebServerTemplate<WiFiServer>::handleClient() at C:\Users\jedrz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\libraries\ESP8266WebServer\src\ESP8266WebServer-impl.h:282
0x40206760: ESP8266WiFiSTAClass::status() at C:\Users\jedrz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\libraries\ESP8266WiFi\src\ESP8266WiFiSTA.cpp:558
0x40204c3f: loop() at C:\Users\jedrz\OneDrive\Dokumenty\Arduino\ATEM_tally_light\ATEM_tally_light.cpp:376
0x402133b8:  is in std::_Function_handler<void(websockets::WebsocketsMessage), loop()::<lambda(websockets::WebsocketsMessage)> >::_M_manager(std::_Any_data &, const std::_Any_data &, std::_Manager_operation) (c:\users\jedrz\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\bits/std_function.h:268).
0x40201120:  is in std::_Function_handler<void(websockets::WebsocketsMessage), loop()::<lambda(websockets::WebsocketsMessage)> >::_M_invoke(const std::_Any_data &, websockets::WebsocketsMessage &&) (c:\users\jedrz\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\bits/invoke.h:103).
0x4020fa99:  is in esp_try_delay(unsigned int, unsigned int, unsigned int) (C:\Users\jedrz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\core_esp8266_main.cpp:169).
0x40100498:  is in __digitalWrite(uint8_t, uint8_t) (C:\Users\jedrz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\core_esp8266_wiring_digital.cpp:85).

if u need any more information, please tell me.

edit:

i found an old issue:
there, it says it may have crashes due to no heap memory, so i printed the memory in a loop. THis is the last print before crash:
======FREE HEAP========
7568

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant