Seeed_Arduino_rpcWiFi icon indicating copy to clipboard operation
Seeed_Arduino_rpcWiFi copied to clipboard

client.connect hangs when Server is not available

Open AVoss18 opened this issue 2 years ago • 4 comments
trafficstars

A first call of "client.connect" waits infinitely when the server is not available. Hardware is WIO Terminal. I have captured the traffic with my fritz box. The WIO Terminal sends arp requests for aprox 10s. After that nothing more happens. The function does not return.

Library Versions used: Seeed_Arduino_rpcWiFi 1.0.6 Seeed_Arduino_rpcUnified 2.1.4 Seeed_Arduino_SFUD 2.0.2 Seeed_Arduino_FS 2.1.1 Seeed_Arduino_mbedtls 3.0.1

The wireless core firmware was updated to 2.1.3

This is the output with ENABLE_ERPC_TRACE:

WiFi connected IP address: FUNC_ENTRY: tcpip_adapter_get_ip_info L#701 FUNC_EXIT: tcpip_adapter_get_ip_info L#722 192.168.1.133 Connecting to 192.168.1.50 FUNC_ENTRY: dns_gethostbyname_addrtype L#59 FUNC_ENTRY: rpc_wifi_dns_found L#17 FUNC_EXIT: rpc_wifi_dns_found L#27 FUNC_EXIT: dns_gethostbyname_addrtype L#90 Return Code : 0 FUNC_ENTRY: lwip_socket L#209 FUNC_EXIT: lwip_socket L#209 FUNC_ENTRY: lwip_fcntl L#298 FUNC_EXIT: lwip_fcntl L#298 FUNC_ENTRY: lwip_fcntl L#298 FUNC_EXIT: lwip_fcntl L#298 FUNC_ENTRY: lwip_connect L#89

AVoss18 avatar Jul 07 '23 12:07 AVoss18

@AVoss18 thanks for the detail I've been having something similar but haven't tracked it down. On my POST If the far-end doesn't respond, periodically it hangs - then i reboot with a WATCHDOG woof - so I recover. A link to discussion https://forum.seeedstudio.com/t/wificlient-connect-192-168-0-10-80-does-not-time-out/258724 I think any support is AWOL.

neilh10 avatar Oct 04 '23 00:10 neilh10

I also experience regular hangups when using the latest rpcWiFi on my WIO terminal to connect and/or disconnect sockets. The terminal uses the latest firmware v2.1.3 on the WiFi end. While tracking down the issue, I managed to bring the thing reliably to a hangup after 1147 iterations using the following minimal example:

#include "rpcWiFi.h"

void setup() {
  uint32_t iteration_count = 0;
  Serial.begin(115200);  // init Serial Port with 115200 baud
  delay(1000);

  /* This is just to make the device "catchable" after power up as after crashing,
    the device typically is not connectable via USB */
  Serial.print("Waiting for 5s before stress test");
  while (millis() < 5000) {
    delay(500);
    Serial.print(".");
  }

  while (millis() < 20000) {
    iteration_count++;
    Serial.printf("%d\t%s\t(%d)\n", millis(), rpc_system_version(), iteration_count);
  }
}

void loop() {
  Serial.println("I'm running...");
  delay(500);
}

Hence I'm not sure whether this is actually related to the rpcWiFi or the underlying RPC mechanism. Any thoughts?

uniederer avatar Oct 04 '23 15:10 uniederer

I've been trying to figure out how to enable the debugging for the rpc libs, and so far found this ... which appears to be some complicated layering, and still haven't got debug output. I wonder if anybody has some insights

At compiler (platformio.ini for me) build_flags = -DCORE_DEBUG_LEVEL=5 ; for rpcUnified Verbose

which in Seeed Arduino rpcUndified\src\esp\esphallog.h is mapped to ARDUHAL_LOG_LEVEL which is then used in #define log_v(format, ...) log_printf(ARDUHAL_LOG_FORMAT(V, format), ##VA_ARGS) #define isr_log_v(format, ...) ets_printf(ARDUHAL_LOG_FORMAT(V, format), ##VA_ARGS)

#define ESP_LOGV(tag, ...) log_v(VA_ARGS)

then in esp_log.h the prototype /** @brief Write message into the log

This function is not intended to be used directly. Instead, use one of
ESP_LOGE, ESP_LOGW, ESP_LOGI, ESP_LOGD, ESP_LOGV macros.

This function or these macros should not be used from an interrupt.

/ void esp_log_write(esp_log_level_t level, const char tag, const char* format, ...) attribute((format(printf, 3, 4)));

and I've not managed to figure out

neilh10 avatar Oct 04 '23 17:10 neilh10

I'm also having the same problem. When sending data with https://github.com/AmbientDataInc/Ambient_ESP8266_lib, it may freeze after exceeding the timeout period. I'm using Seeed_Arduino_rpcWiFi 1.0.6.

Seeed_Arduino_rpcWiFi says "Maximum Compatible with ESP32 wifi library", but I would like to know how the timeout processing is different.

todateman avatar Jan 21 '24 08:01 todateman