Data reception delay at socket

Hello,

2021-07-12T18:30:00Z

I am facing a delay in data reception while using socket security (mbedTLS yotta 2.3.2).
Scenario:
I have added socket security using mbedTLS.
When a payload of 5kb is sent from cloud, I am receiving the data in 3 chunks(expected) with 2k, 2k and 1k via socket at the device. “select” socket call is used for data polling at socket.
select call is implemented as below in my code:

API()
{
	fd_set read_fds, write_fds, except_fds;
	int channel_fd = 0;
	timeval stSelect;
	stSelect.tv_sec = 0;
	stSelect.tv_usec = 100000

    FD_ZERO(&read_fds);
    FD_ZERO(&write_fds);
    FD_ZERO(&except_fds);
	
	    if (channel_is_ready(&client->channel, FD_READ))
        FD_SET(channel_fd, &read_fds);

    if (channel_is_ready(&client->channel, FD_WRITE))
        FD_SET(channel_fd, &write_fds);
	
	int poll_result = select(channel_fd + 1, &read_fds, &write_fds, NULL, &stSelect);
    if (poll_result == 0) {
       check_if_alive();
    } else if (poll_result > 0) {
        if (channel_fd >= 0) {
            if (FD_ISSET(channel_fd, &read_fds)) {
			    // read 2kb at once
			}
            if (FD_ISSET(channel_fd, &write_fds)) {
		       // do something...
			}
	}
	FD_CLR(0, &read_fds);
    FD_CLR(0, &write_fds);
    FD_CLR(0, &except_fds);
}

Issue:
But there is a delay of around 50 sec to 2 minutes in between the 1st(2kb) and 2nd(2kb) chunk, which is totally unexpected. 2nd(2kb) and 3rd(1kb) chunk are received without delay(expected) on socket.
Without socket security(mbedTLS), the data reception works perfectly fine i.e there is no delay while receiving
data in chunks at the socket.
I have tested and faced the same issue in GSM, Ethernet, and WiFi interfaces.

What could be the reason? I tried finding solutions online but in vain.

Hello,

I have a major release this week. So please look into this issue as soon as possible.