diff --git a/libraries/coreMQTT/port/network_transport/network_transport.c b/libraries/coreMQTT/port/network_transport/network_transport.c index b5c38c723..3a6daa5c9 100644 --- a/libraries/coreMQTT/port/network_transport/network_transport.c +++ b/libraries/coreMQTT/port/network_transport/network_transport.c @@ -202,7 +202,7 @@ int32_t espTlsTransportSend( NetworkContext_t* pxNetworkContext, int32_t espTlsTransportRecv( NetworkContext_t* pxNetworkContext, void* pvData, size_t uxDataLen ) { - int32_t lBytesRead = 0; + int32_t lBytesRead = -1; if( ( pvData != NULL ) && ( uxDataLen > 0 ) && @@ -222,6 +222,8 @@ int32_t espTlsTransportRecv( NetworkContext_t* pxNetworkContext, fd_set read_fds; fd_set error_fds; + lBytesRead = 0; + esp_tls_get_conn_sockfd( pxNetworkContext->pxTls, &lSockFd ); FD_ZERO( &read_fds ); FD_SET( lSockFd, &read_fds );