Issue Facing on Sending Data Through TCP Socket Client on WiFi Network

Hi Support Team,

I have an nRF7002 DK board and I am using SDK v2.6.0. I am facing an issue when sending data from the client to the server. Below are the steps taken:
1.WiFi connect [SUCCESS]
2.Initialize TCP thread [SUCCESS]
3.API inet_pton [SUCCESS] - Initialize server address
4.API socket [SUCCESS] - Create socket
5.API connect [SUCCESS] - Connect to the server (Local server is running and successfully connected to the client)
6.API send [Partially success] - Send data to the server (Data is sent successfully but after some time it is not able to send data)

please sahre us,if you have some exmpale for TCP client sid with WiFi network on nrf7002dk board

Below I have attached the log:
Code:

const char message[10] = "Hello";
ssize_t len = send(sockfd, message, sizeof(message), MSG_DONTWAIT);
if (len < 0)
{
LOG_ERR("Failed to send data: %d", errno);
} else {
LOG_INF("Sent %zd bytes to server ", len);
}

k_sleep(K_MSEC(500));

prg.conf file

# Below section is the primary contributor to SRAM and is currently
# tuned for performance, but this will be revisited in the future.
CONFIG_NET_PKT_TX_COUNT=32
CONFIG_NET_PKT_RX_COUNT=16
CONFIG_NET_BUF_TX_COUNT=32
CONFIG_NET_BUF_RX_COUNT=16
CONFIG_NET_BUF_DATA_SIZE=3000
CONFIG_HEAP_MEM_POOL_SIZE=180000
#CONFIG_SPEED_OPTIMIZATIONS=y
#CONFIG_NRF700X_MAX_TX_AGGREGATION=9
#CONFIG_NRF700X_MAX_TX_TOKENS=12
CONFIG_NET_TC_TX_COUNT=1
ONFIG_NET_TC_TX_COUNT=1

# Below configs will increase tcp connection timeout
CONFIG_NET_TCP_ACK_TIMEOUT=60000
CONFIG_NET_TCP_INIT_RETRANSMISSION_TIMEOUT=1000
CONFIG_NET_SOCKETS_CONNECT_TIMEOUT=10000
CONFIG_NET_TCP_RETRY_COUNT=10

CONFIG_NET_IF_UNICAST_IPV4_ADDR_COUNT=1
CONFIG_NET_MAX_CONTEXTS=5
CONFIG_NET_CONTEXT_SYNC_RECV=y

CONFIG_INIT_STACKS=y

CONFIG_NET_L2_ETHERNET=y

CONFIG_NET_CONFIG_SETTINGS=y
CONFIG_NET_CONFIG_INIT_TIMEOUT=0

CONFIG_NET_SOCKETS_POLL_MAX=10

# Memories
CONFIG_MAIN_STACK_SIZE=16384
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
CONFIG_NET_TX_STACK_SIZE=4096
CONFIG_NET_RX_STACK_SIZE=4096

Nrfside console Log
[00:00:37.232,086] <inf> WIFI_TCP_LOG: Successed connect to server: 116
[00:00:39.232,971] <inf> WIFI_TCP_LOG: Sent 10 bytes to server
[00:00:39.733,703] <inf> WIFI_TCP_LOG: Sent 10 bytes to server
[00:00:40.233,856] <inf> WIFI_TCP_LOG: Sent 10 bytes to server
[00:00:40.734,008] <inf> WIFI_TCP_LOG: Sent 10 bytes to server
[00:00:41.234,741] <inf> WIFI_TCP_LOG: Sent 10 bytes to server
[00:00:41.735,473] <inf> WIFI_TCP_LOG: Sent 10 bytes to server
[00:00:42.236,236] <inf> WIFI_TCP_LOG: Sent 10 bytes to server
[00:00:42.736,968] <inf> WIFI_TCP_LOG: Sent 10 bytes to server
[00:00:43.237,731] <inf> WIFI_TCP_LOG: Sent 10 bytes to server
[00:00:43.738,494] <inf> WIFI_TCP_LOG: Sent 10 bytes to server
[00:00:44.239,227] <inf> WIFI_TCP_LOG: Sent 10 bytes to server
[00:00:44.739,990] <inf> WIFI_TCP_LOG: Sent 10 bytes to server
[00:00:45.240,722] <inf> WIFI_TCP_LOG: Sent 10 bytes to server
[00:00:45.741,485] <inf> WIFI_TCP_LOG: Sent 10 bytes to server
[00:00:46.242,218] <inf> WIFI_TCP_LOG: Sent 10 bytes to server
[00:00:46.742,980] <inf> WIFI_TCP_LOG: Sent 10 bytes to server
[00:00:47.243,743] <inf> WIFI_TCP_LOG: Sent 10 bytes to server
[00:00:47.348,480] <wrn> net_conn: pkt cloning failed, pkt 0x2006e414 dropped
[00:00:47.744,476] <inf> WIFI_TCP_LOG: Sent 10 bytes to server
[00:00:48.244,628] <inf> WIFI_TCP_LOG: Sent 10 bytes to server
[00:00:48.744,750] <inf> WIFI_TCP_LOG: Sent 10 bytes to server
[00:01:59.261,016] <inf> WIFI_TCP_LOG: Sent 10 bytes to server
[00:01:59.761,108] <inf> WIFI_TCP_LOG: Sent 10 bytes to server
[00:02:00.261,230] <inf> WIFI_TCP_LOG: Sent 10 bytes to server
[00:02:10.821,472] <err> WIFI_TCP_LOG: Failed to send data: 105
[00:02:21.381,744] <err> WIFI_TCP_LOG: Failed to send data: 105
[00:02:31.942,230] <err> WIFI_TCP_LOG: Failed to send data: 105
[00:02:42.502,471] <err> WIFI_TCP_LOG: Failed to send data: 105
[00:02:44.641,632] <err> WIFI_TCP_LOG: Failed to send data: 128
[00:02:45.141,754] <err> WIFI_TCP_LOG: Failed to send data: 128
[00:02:45.641,876] <err> WIFI_TCP_LOG: Failed to send data: 128
[00:02:46.141,967] <err> WIFI_TCP_LOG: Failed to send data: 128
[00:02:46.642,089] <err> WIFI_TCP_LOG: Failed to send data: 128
[00:02:47.142,211] <err> WIFI_TCP_LOG: Failed to send data: 128
[00:02:47.642,303] <err> WIFI_TCP_LOG: Failed to send data: 128

  • Code:

    memset(&server_addr, 0, sizeof(server_addr));
    server_addr.sin_family = AF_INET;
    server_addr.sin_port = htons(CONFIG_TRAFFIC_GEN_REMOTE_PORT_NUM);
    if (inet_pton(AF_INET, CONFIG_TRAFFIC_GEN_REMOTE_IPV4_ADDR, &server_addr.sin_addr) <= 0)
    {
    LOG_ERR("Failed to set server address ");
    close(sockfd);
    return;
    }
    /* Create socket */
    sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
    if (sockfd < 0)
    {
    LOG_ERR("Failed to create socket: %d", errno);
    return;
    }
    /* Connect to the server */

    err = connect(sockfd, (struct sockaddr *)&server_addr, sizeof(server_addr));
    if (err < 0)
    {
    LOG_ERR("Failed to connect to server: %d", errno);
    close(sockfd);
    }
    else
    {
    LOG_INF("Successed connect to server: %d", errno);
    }
    After every 1 sec send data

    const char message[10] = "Hello";
    ssize_t len = send(sockfd, message, sizeof(message), MSG_DONTWAIT);
    if (len < 0)
    {
    LOG_ERR("Failed to send data: %d", errno);
    } else {
    LOG_INF("Sent %zd bytes to server ", len);
    }

    k_sleep(K_MSEC(500));

  • Hi

    No, unfortunately we don't have a sample project for a TCP client over Wi-Fi other than the TCP test you seem to have based your sample from, but could the http_client sample be of any use to you here perhaps.

    The error message seems to indicate that there is no more buffer space available, so please try increasing the buffer size for either the Packet count or buffer count configs or potentially the NET stack size and possibly the main stack size.

    Best regards,

    Simon

Related