2020-02-13 10:09 PM
I am using X-CUBE-AWS packages with p-l496g-cell01 development board to send my sensor data on AWS it works fine buy during sometime code will stick and it generates an error
I also enable "isAutoReconnectEnabled" flag but it genrate error like
ERROR: ../../../../../../Middlewares/ST/STM32_Connect_Library/services/net_mbedtls.c:367 failed
! mbedtls_ssl_read returned -0x7880
ERROR: iot_tls_read L#209 net_recv failed - -109
2000aaf8 => ../../../../../../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:6940: => read
2000aaf8 => ../../../../../../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:3809: => read record
2000aaf8 => ../../../../../../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:2252: => fetch input
2000aaf8 => ../../../../../../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:2412: in_left: 0, nb_want: 5
com_recv in progress of 5 bytes
2000aaf8 => ../../../../../../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:2436: in_left: 0, nb_want: 5
2000aaf8 => ../../../../../../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:7330: => write
2000aaf8 => ../../../../../../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:2764: => write record
2000aaf8 => ../../../../../../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:1287: => encrypt buf
2000aaf8 => ../../../../../../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:1443: before encrypt: msglen = 10, including 0 bytes of padding
2000aaf8 => ../../../../../../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:1605: <= encrypt buf
2000aaf8 => ../../../../../../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:2907: output record: msgtype = 23, version = [3:3], msglen = 26
2000aaf8 => ../../../../../../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:2471: => flush output
2000aaf8 => ../../../../../../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:2489: message length: 31, out_left: 31
Trying to send (31) on socket 0
ERROR: ../../../../../../Middlewares/ST/STM32_Connect_Library/netif/cellular_if/net_cellular.c:671 Send failed : 4294967290
ERROR: ../../../../../../Middlewares/ST/STM32_Connect_Library/services/net_mbedtls.c:490 mbedtls_net_send(): error -21 in send() - requestedLen=31
2000aaf8 => ../../../../../../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:2496: ssl->f_send() returned -30848 (-0x7880)
2000aaf8 => ../../../../../../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:2918: mbedtls_ssl_flush_output() returned -30848 (-0x7880)
2000aaf8 => ../../../../../../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:7277: mbedtls_ssl_write_record() returned -30848 (-0x7880)
2000aaf8 => ../../../../../../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:7358: <= write
ERROR: ../../../../../../Middlewares/ST/STM32_Connect_Library/services/net_mbedtls.c:387 failed
! mbedtls_ssl_write returned -0x7880
ERROR: iot_tls_write L#165 failed
! mbedtls_ssl_write returned -0x6d
2000aaf8 => ../../../../../../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:7373: => write close notify
2000aaf8 => ../../../../../../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:2471: => flush output
2000aaf8 => ../../../../../../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:2489: message length: 31, out_left: 31
Trying to send (31) on socket 0
ERROR: ../../../../../../Middlewares/ST/STM32_Connect_Library/netif/cellular_if/net_cellular.c:671 Send failed : 4294967290
ERROR: ../../../../../../Middlewares/ST/STM32_Connect_Library/services/net_mbedtls.c:490 mbedtls_net_send(): error -21 in send() - requestedLen=31
2000aaf8 => ../../../../../../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:2496: ssl->f_send() returned -30848 (-0x7880)
2000aaf8 => ../../../../../../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:7542: => free
2000aaf8 => ../../../../../../Middlewares/Third_Party/mbedTLS/library/ssl_tls.c:7607: <= free
Trying to close socket 0
socket 0 is now closed
WARN: disconnectCallbackHandler L#149 MQTT Disconnect
Auto Reconnect is enabled, Reconnecting attempt will start now
In short my reconnection is not working and code will be stuck
Any one idea about this
2020-07-22 06:19 AM
Hello,
The message 0x7880 is described here : https://tls.mbed.org/api/ssl_8h.html . It means that “The peer notified us that the connection is going to be closed�? . But in fact this message is the one returned by the socket wrapperbelow MbedTLS , see file “net_mbedtls.c�? , at that stage the wrapper miss information to make the distinction between the different error case.
MBEDTLS_ERR_SSL_INTERNAL_ERROR,
MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY,
MBEDTLS_ERR_SSL_CONN_EOF.
So in case of error , the wrapper always return the "MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY" error. This happen while performing a write to a socket, see functionbelow.
The error is coming the lower part of the stack ,the Cellular driver is the one which returns this error. So shoul add Cellular tag to this issue to see if cellular competent people can help.
Br,
Jean-Marc
static int32_t mbedtls_net_send(void *ctx, const uchar_t *buf, size_t len)
if (pSocket->write_timeout == 0)
{
flags = (int8_t) NET_MSG_DONTWAIT;
}
UNLOCK_SOCK(pSocket->idx);
/*cstat -MISRAC2012-Rule-11.8 removing const attribute */
ret = pSocket->pnetif->pdrv->psend(pSocket->ulsocket, (uchar_t *) buf, len, flags);
/*cstat +MISRAC2012-Rule-11.8 */
LOCK_SOCK(pSocket->idx);
if (ret >= 0)
{
if (ret == 0)
{
ret = MBEDTLS_ERR_SSL_WANT_WRITE;
}
}
else
{
NET_DBG_ERROR("mbedtls_net_send(): error %ld in send() - requestedLen=%d\n", ret, len);
/* TODO: The underlying layers do not allow to distinguish between
* MBEDTLS_ERR_SSL_INTERNAL_ERROR,
* MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY,
* MBEDTLS_ERR_SSL_CONN_EOF.
* Most often, the error is due to the closure of the connection by the remote host. */
ret = MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY;
}