Connecting Loop - SSL_HANDSHAKE_FAILED

I have two Tidbyts and both are stuck in a “Connecting” loop, which began a few days ago. Resets have not resolved the issue.

I can successfully browse to “https://connect.tidbyt.com?deviceID=xxx” from another device on the same network and see the JSON response.

Error log messages:

E (11682) esp-tls-mbedtls: mbedtls_ssl_handshake returned -0x004C
E (11682) esp-tls: Failed to open new connection
E (11682) TRANSPORT_BASE: Failed to open a new connection
E (11732) HTTP_CLIENT: Connection failed, sock < 0
E (11732) tidbyt/connect: HTTP_EVENT_ERROR
E (11732) tidbyt/connect: couldn’t reach https://connect.tidbyt.com?deviceID=[redacted]: ESP_ERR_HTTP_CONNECT
E (11742) tidbyt/connect: HTTP error - ESP_ERR_MBEDTLS_SSL_HANDSHAKE_FAILED (mbedtls: 0x4c)
connected with [redacted], aid = 31, channel 7, BW20, bssid = [redacted]
E (11752) tidbyt/cloud: Error retrieving connection profile: ESP_ERR_HTTP_CONNECT
security: WPA2-PSK, phy: bgn, rssi: -38
E (11772) tidbyt/connect: Failed to connect: ESP_ERR_HTTP_CONNECT
E (11872) tidbyt: Couldn’t find handler for state: ERROR (-1).

Could you please share the portion of the log that lists memory stats (free memory and high watermark)?

Also would be great to know more about your network like the router and ISP.

Below is a full log.

Router is an Asus RT-AX3000, and has not had issues supporting Tidbyt devices until a few days ago.

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:2
load:0x3fff0030,len:6620
ho 0 tail 12 room 4
load:0x40078000,len:14788
load:0x40080400,len:3792
entry 0x40080694
I (29) boot: ESP-IDF 0.0.0+sha.a0c081b5a 2nd stage bootloader
I (29) boot: compile time 20:33:14
I (29) boot: chip revision: 3
I (33) boot_comm: chip revision: 3, min. bootloader chip revision: 0
I (40) boot.esp32: SPI Speed : 40MHz
I (45) boot.esp32: SPI Mode : DIO
I (49) boot.esp32: SPI Flash Size : 8MB
I (54) boot: Enabling RNG early entropy source…
I (59) boot: Partition Table:
I (63) boot: ## Label Usage Type ST Offset Length
I (70) boot: 0 nvs WiFi data 01 02 00009000 00005000
I (78) boot: 1 otadata OTA data 01 00 0000e000 00002000
I (85) boot: 2 app0 OTA app 00 10 00010000 003f0000
I (93) boot: 3 app1 OTA app 00 11 00400000 003f0000
I (100) boot: End of partition table
I (104) boot_comm: chip revision: 3, min. application chip revision: 0
I (111) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=502f0h (328432) map
I (239) esp_image: segment 1: paddr=00060318 vaddr=3ffbdb60 size=050ach ( 20652) load
I (247) esp_image: segment 2: paddr=000653cc vaddr=40080000 size=0ac4ch ( 44108) load
I (266) esp_image: segment 3: paddr=00070020 vaddr=400d0020 size=eca90h (969360) map
I (617) esp_image: segment 4: paddr=0015cab8 vaddr=4008ac4c size=152cch ( 86732) load
I (652) esp_image: segment 5: paddr=00171d8c vaddr=50000000 size=00010h ( 16) load
I (668) boot: Loaded app from partition at offset 0x10000
I (668) boot: Disabling RNG early entropy source…
I (680) psram: This chip is ESP32-D0WD
I (680) spiram: Found 64MBit SPI RAM device
I (681) spiram: SPI RAM mode: flash 40m sram 40m
I (685) spiram: PSRAM initialized, cache is in low/high (2-core) mode.
I (693) cpu_start: Pro cpu up.
I (696) cpu_start: Starting app cpu, entry point is 0x40082b1c
I (0) cpu_start: App cpu up.
I (735) cpu_start: Pro cpu start user code
I (735) cpu_start: cpu freq: 160000000
I (735) cpu_start: Application information:
I (738) cpu_start: Project name: tidbyt
I (743) cpu_start: App version: 26961
I (748) cpu_start: Compile time: Apr 20 2023 16:11:32
I (754) cpu_start: ELF file SHA256: cc9cca2abfe1c46b…
I (760) cpu_start: ESP-IDF: 4.4.1
I (765) heap_init: Initializing. RAM available for dynamic allocation:
I (772) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
I (778) heap_init: At 3FFB6388 len 00001C78 (7 KiB): DRAM
I (784) heap_init: At 3FFB9A20 len 00004108 (16 KiB): DRAM
I (790) heap_init: At 3FFC84F0 len 00017B10 (94 KiB): DRAM
I (796) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (803) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (809) heap_init: At 4009FF18 len 000000E8 (0 KiB): IRAM
I (815) spiram: Adding pool of 4095K of external SPI memory to heap allocator
I (824) spi_flash: detected chip: gd
I (827) spi_flash: flash io: dio
I (833) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (842) spiram: Reserving pool of 32K of internal memory for DMA/internal allocations
I (862) tidbyt: Entering state BOOT (1).
I (862) tidbyt: free memory - exec: 124608, internal: 207043, DMA: 207043, malloc: 4367775
I (862) tidbyt/boot: Initializing high-resolution timers…
I (872) tidbyt/boot: Initialized high-resolution timers.
I (862) tidbyt: memory low watermark - exec: 124608, internal: 203031, DMA: 203031, malloc: 4363763
I (882) gpio: GPIO[15]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:3
I (892) tidbyt/boot: Initializing non-volatile storage…
I (942) tidbyt/boot: Initialized non-volatile storage.
I (942) tidbyt/boot: Initializing configuration system…
I (952) tidbyt/boot: Initialized configuration system.
I (952) tidbyt/boot: ESP chip model: 1
I (952) tidbyt/boot: ESP silicon revision: 3
I (962) tidbyt/boot: ESP flash size: 8388608
I (962) tidbyt/boot: Build environment: tidbyt-v10
I (972) tidbyt/boot: Hardware rev 0x00
I (972) system_api: Base MAC address is not set
I (982) system_api: read default base MAC address from EFUSE
I (982) tidbyt/boot: Bluetooth MAC: E05A1B194072
I (992) tidbyt/boot: Initializing display…
I (992) gpio: GPIO[21]| InputEn: 1| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (1002) gpio: GPIO[23]| InputEn: 1| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (1012) gpio: GPIO[2]| InputEn: 1| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (1022) gpio: GPIO[4]| InputEn: 1| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (1032) gpio: GPIO[22]| InputEn: 1| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (1042) gpio: GPIO[27]| InputEn: 1| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (1052) gpio: GPIO[33]| InputEn: 1| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (1062) gpio: GPIO[19]| InputEn: 1| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (1072) gpio: GPIO[32]| InputEn: 1| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (1092) tidbyt/display_queue: Display for rev 0, RGB=2,0,1
I (1092) tidbyt/display_queue: Updating screen duration to 15000ms
I (1092) tidbyt/boot: Initialized display.
I (1092) tidbyt/sprites: Loading sprite 0 from asset (2806 bytes)
E (1102) tidbyt/display_queue: nothing to draw to the display
I (1112) tidbyt/boot: Initializing wifi…
I (1152) wifi:wifi driver task: 3ffdf594, prio:23, stack:6656, core=0
I (1202) wifi:wifi firmware version: 63017e0
I (1202) wifi:wifi certification version: v7.0
I (1202) wifi:config NVS flash: enabled
I (1202) wifi:config nano formating: disabled
I (1202) wifi:Init data frame dynamic rx buffer num: 32
I (1212) wifi:Init management frame dynamic rx buffer num: 32
I (1212) wifi:Init management short buffer num: 32
I (1222) wifi:Init static tx buffer num: 16
I (1222) wifi:Init tx cache buffer num: 32
I (1222) wifi:Init static rx buffer size: 1600
I (1232) wifi:Init static rx buffer num: 8
I (1232) wifi:Init dynamic rx buffer num: 32
I (1252) wifi_init: tcpip mbox: 32
I (1252) wifi_init: udp mbox: 6
I (1252) wifi_init: tcp mbox: 6
I (1252) wifi_init: tcp tx win: 5744
I (1252) wifi_init: tcp rx win: 5744
I (1262) wifi_init: tcp mss: 1440
I (1262) wifi_init: WiFi/LWIP prefer SPIRAM
I (1272) wifi_init: WiFi IRAM OP enabled
I (1272) wifi_init: WiFi RX IRAM OP enabled
I (1282) tidbyt/boot: Initialized wifi.
I (1282) tidbyt/boot: Wifi MAC: e05a1b194070
I (1292) tidbyt/boot: Initializing Bluetooth…
I (1332) BTDM_INIT: BT controller compile version [5688ed5]
I (1342) phy_init: phy_version 4670,719f9f6,Feb 18 2021,17:07:07
I (1812) tidbyt/boot: Initialized UART.
I (1812) tidbyt/boot: Initializing I2C…
I (1812) tidbyt/boot: Initialized I2C…
I (1912) tidbyt: Entering state CONNECT (3).
I (1912) tidbyt/ble: Not sending event (2) since no peer connected
I (1912) tidbyt: free memory - exec: 56860, internal: 58279, DMA: 58279, malloc: 4153323
I (1922) tidbyt: memory low watermark - exec: 56860, internal: 58107, DMA: 58107, malloc: 4140127
I (1912) tidbyt/connect: Configuring wifi network: [redacted]
I (1952) tidbyt/cloud: using device status topic: /devices/[redacted]/state
I (1952) tidbyt/cloud: using heartbeat topic: /devices/[redacted]/events/heartbeat
I (1962) tidbyt/crypto: Parsed private key with bit length 256.
I (1972) tidbyt/crypto: Using ECDSA with public key:
-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE97GJ9rpBuiDHy9JnxgxWk/08b3RI
ZUptnimsAlADabZ7TiurnWu0xo/YTa16ptAjxLw/unICJDCuVfjXDYJ+TA==
-----END PUBLIC KEY-----

I (1992) wifi:mode : sta (e0:5a:1b:19:40:70)
I (1992) wifi:enable tsf
I (2002) tidbyt/wifi: SYSTEM_EVENT_STA_START wifi connecting…
I (2022) tidbyt/sprites: Loading sprite 3 from asset (29868 bytes)
I (2042) tidbyt/ble: Not sending event (3) since no peer connected
I (2052) wifi:new:<7,0>, old:<1,0>, ap:<255,255>, sta:<7,0>, prof:1
I (2052) wifi:state: init → auth (b0)
I (2072) wifi:state: auth → assoc (0)
I (2082) wifi:state: assoc → run (10)
I (2112) wifi:connected with [redacted], aid = 19, channel 7, BW20, bssid = c8:7f:54:90:f3:c0
I (2112) wifi:security: WPA2-PSK, phy: bgn, rssi: -46
I (2122) wifi:pm start, type: 1

I (2122) tidbyt/wifi: SYSTEM_EVENT_STA_CONNECTED connected…
I (2142) tidbyt/wifi: SYSTEM_EVENT_STA_GOT_IP IP assigned…
I (2142) esp_netif_handlers: sta ip: 192.168.50.138, mask: 255.255.255.0, gw: 192.168.50.1
I (2142) tidbyt/ble: Not sending event (5) since no peer connected
I (2152) tidbyt/ble: Not sending event (6) since no peer connected
I (2152) wifi:AP’s beacon interval = 102400 us, DTIM period = 1
I (2172) wifi:sta rx csa, newchan=1, old=7
I (2202) tidbyt/connect: Downloading connection profile from: https://connect.tidbyt.com?deviceID=[redacted]
I (2262) wifi:sta rx csa, newchan=1, old=7
I (2362) wifi:sta rx csa, newchan=1, old=7
I (2462) wifi:sta rx csa, newchan=1, old=7
I (2562) wifi:sta rx csa, newchan=1, old=7
I (2672) wifi:sta rx csa, newchan=1, old=7
I (2772) wifi:sta rx csa, newchan=1, old=7
I (2872) wifi:sta rx csa, newchan=1, old=7
I (2972) wifi:sta rx csa, newchan=1, old=7
I (3082) wifi:sta rx csa, newchan=1, old=7
I (3182) wifi:sta rx csa, newchan=1, old=7
I (3272) wifi:switch to channel 1
I (3272) wifi:new:<1,0>, old:<7,0>, ap:<255,255>, sta:<1,0>, prof:1
I (9182) wifi:bcn_timout,ap_probe_send_start
I (11692) wifi:ap_probe_send over, resett wifi status to disassoc
I (11692) wifi:state: run → init (c800)
I (11692) wifi:pm stop, total sleep time: 880353 us / 9566478 us

I (11692) wifi:new:<1,0>, old:<1,0>, ap:<255,255>, sta:<1,0>, prof:1
I (11702) tidbyt/wifi: SYSTEM_EVENT_STA_DISCONNECTED reason code: 200
I (11722) wifi:new:<7,0>, old:<1,0>, ap:<255,255>, sta:<7,0>, prof:1
I (11722) wifi:state: init → auth (b0)
E (11732) esp-tls-mbedtls: mbedtls_ssl_handshake returned -0x004C
E (11732) esp-tls: Failed to open new connection
E (11732) TRANSPORT_BASE: Failed to open a new connection
I (11732) wifi:state: auth → assoc (0)
E (11752) HTTP_CLIENT: Connection failed, sock < 0
E (11752) tidbyt/connect: HTTP_EVENT_ERROR
I (11752) wifi:E (11752) tidbyt/connect: couldn’t reach https://connect.tidbyt.com?deviceID=[redacted]: ESP_ERR_HTTP_CONNECT
state: assoc → run (10)
I (11782) wifi:sta rx csa, newchan=1, old=7
I (11792) wifi:connected with [redacted], aid = 17, channel 7, BW20, bssid = [redacted] (11772) tidbyt/connect: HTTP error - ESP_ERR_MBEDTLS_SSL_HANDSHAKE_FAILED (mbedtls: 0x4c)

I (11802) wifi:security: WPA2-PSK, phy: bgn, rssi: -49
E (11802) tidbyt/cloud: Error retrieving connection profile: ESP_ERR_HTTP_CONNECT
I (11812) wifi:E (11812) tidbyt/connect: Failed to connect: ESP_ERR_HTTP_CONNECT
pm start, type: 1

I (11822) tidbyt/wifi: SYSTEM_EVENT_STA_CONNECTED connected…
I (11872) tidbyt/wifi: SYSTEM_EVENT_STA_GOT_IP IP assigned…
I (11872) esp_netif_handlers: sta ip: 192.168.50.138, mask: 255.255.255.0, gw: 192.168.50.1
I (11882) wifi:AP’s beacon interval = 102400 us, DTIM period = 1
I (11882) wifi:sta rx csa, newchan=1, old=7
I (11882) tidbyt: Entering state ERROR (-1).
E (11892) tidbyt: Couldn’t find handler for state: ERROR (-1).
W (11892) tidbyt: Handler loop suspended due to error, restarting in 5 seconds.
I (11992) wifi:sta rx csa, newchan=1, old=7
I (12092) wifi:sta rx csa, newchan=1, old=7
I (12192) wifi:sta rx csa, newchan=1, old=7
I (12292) wifi:sta rx csa, newchan=1, old=7
I (12402) wifi:sta rx csa, newchan=1, old=7
I (12502) wifi:sta rx csa, newchan=1, old=7
I (12602) wifi:sta rx csa, newchan=1, old=7
I (12702) wifi:sta rx csa, newchan=1, old=7
I (12802) wifi:sta rx csa, newchan=1, old=7
I (12882) wifi:switch to channel 1
I (12882) wifi:new:<1,0>, old:<7,0>, ap:<255,255>, sta:<1,0>, prof:1
W (12922) tidbyt: Handler loop suspended due to error, restarting in 4 seconds.
W (13922) tidbyt: Handler loop suspended due to error, restarting in 3 seconds.
W (14932) tidbyt: Handler loop suspended due to error, restarting in 2 seconds.
W (15942) tidbyt: Handler loop suspended due to error, restarting in 1 seconds.
W (16952) tidbyt: Handler loop suspended due to error, restarting in 0 seconds.
W (17962) tidbyt: Restarting…
I (17992) wifi:state: run → init (0)
I (17992) wifi:pm stop, total sleep time: 660059 us / 6166020 us

I (17992) wifi:new:<1,0>, old:<1,0>, ap:<255,255>, sta:<1,0>, prof:1
W (17992) wifi:age timer already deinit
I (18002) tidbyt/wifi: SYSTEM_EVENT_STA_DISCONNECTED reason code: 8
W (18002) wifi:hmac tx: ifx0 stop, discard
W (32642) wifi:TX Q not empty: 500, TXQ_BLOCK=0
W (32642) wifi:force witi stop
I (32642) wifi:flush txq
I (32642) wifi:stop sw txq
I (32642) wifi:lmac stop hw txq
W (32642) wifi:sw tx 0 state not idle, potential error!
W (32642) wifi:force sw tx 0 state to idle, ebuf flag=0
W (32652) tidbyt/display: permanently shutting off display
ets Jul 29 2019 12:21:46

Upon trying a factory reset, the app gives the error “Couldn’t connect to Tidbyt’s servers” after setting up the device.

Thanks for all the additional details. This is going to take some time to sort through and determine exactly what’s going on and roll out a fix (if necessary).

At a cursory inspection though, I think if you are able to switch the 2.4 GHz channel on your router/AP to a different channel, it may get you back up and running.

Changing the WiFi control channel (from 7 to 4) did get them back connected.

Changing the channel back to 7 and restarting the Tidbyts seems to work as well, so it is possible it was the WiFi router needing a restart.