Closed mitchellhansen-wyze closed 2 years ago
@mitchellhansen-wyze
From my understanding, you don't want your program to re-initialize when a MbedTLS error happens in Kvs_putMediaDoWork
, right?
There are several possible MbedTLS error codes while error happens in mbedtls_ssl_read, and MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY
is one of them. So even if we don't treat MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY
as an error, other actual MbedTls errors still cause your program re-initialize.
In my opinion, I tend to cache the error code (Ex. MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY
) and the error type (Ex. MbedTLS error) in the KVS library, and then the application can get it and decide what to do with the error. Is that sound good to you?
@weichihl
From my understanding, you don't want your program to re-initialize when a MbedTLS error happens in Kvs_putMediaDoWork, right?
More or less, yes. Mainly I need Kvs_putMediaDoWork
to either return only fatal errors, or return a more descriptive error code than just a KVS_ERRNO_NONE
or KVS_ERRNO_FAIL
.
I like your suggestion, where Kvs_putMediaDoWork
would return the same error codes, but the underlying error would be cached in some sort of errno
like structure. Then I can query it, and decide on my end whether or not the error was fatal.
Are you maintaining this repository @weichihl? is it possible that this improvement could be applied?
@mitchellhansen-wyze Yeah, I can make the change. I'll draft the solution and attach the PR here once it's available.
Excellent, thank you @weichihl!
@mitchellhansen-wyze I've merged the PR. Please check if this helps, and feel free to reopen this issue if you need more help.
Hello!
I have a program that integrates this library. When calling the final
Kvs_putMediaDoWork
in a stream, it will receive a-0x7880
:MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY
error from the mbedtls layers.my_program.c
netio.c
@ line311
The error message from KVS:
Discussion about this specific mbedtls API : https://github.com/Mbed-TLS/mbedtls/issues/2173
My program will attempt to reinitialize the library when
Kvs_putMediaDoWork
returns bad error codes. But thisMBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY
error (according to the linked discussion) is not a fatal error, and should not affect program behaviour.Tweaking this function to :
Stops the error from occurring, and lets my program re-initialize only when there are fatal errors within the function.
Though oddly enough, this now exposes another issue, in which
mbedtls_ssl_read
will return-76
(MBEDTLS_ERR_NET_RECV_FAILED
) on occasion, again causing my code to re-initialize the moduleIs this change (to ignore
MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY
) an acceptable change to upstream to this repo? And, has any other user of this repo run into these problems?