JKRhb / dtls2

A DTLS library for Dart based on OpenSSL.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Check bytesSent at every invocation of _maintainOutgoing() and if 0 throw Network Unreachable

Ifilehk opened this issue · comments

Hello Jan

Back again with an issue. Getting a network unreachable unhandled exception during a _dtlsClient._socket.send in dtls_client.dart _maintainOutgoing() line 559.

I suppose that every _maintainOutgoing() invocation has to be checked on the number of sent bytes and throw Network unreachable consequently.

Server side might need the same ...

Hi @Ifilehk, welcome back and thank you for reporting this issue!

I suppose that every _maintainOutgoing() invocation has to be checked on the number of sent bytes and throw Network unreachable consequently.

So would you suggest that a SocketException should be thrown if the number of bytes sent is equal to 0? Or would another behavior be better here?

I think that the answer should be an exception + connection close and cleanings because for what ever reason the network adapter has been deactivated. So no reason to continue with the current connection.

Hi @Ifilehk, sorry for the delay! I tried to come up with a fix in #75, could you try out if that resolves the issue?

No problem !!!

Will give a try and let you know

Here my comments:

On client side:
A Exception: DtlsException: Sending failed: Not connected is thrown. I would expect a SocketException Network unreachable. Otherwise behavior seems to be OK.

On server side:
On Ubuntu, unfortunately the invocation of _dtlsServer._socket.send doesn't return 0 on Network unreachable. The app crashes with the system exception Network unreachable without possibility to catch it.

Will open an issue there to have at least the same behavior seen on Android.

Thank you for your feedback!

On client side:
A Exception: DtlsException: Sending failed: Not connected is thrown. I would expect a SocketException > Network unreachable. Otherwise behavior seems to be OK.

I will update #75 accordingly :)

On server side:
On Ubuntu, unfortunately the invocation of _dtlsServer._socket.send doesn't return 0 on Network unreachable. The app crashes with the system exception Network unreachable without possibility to catch it.

Will open an issue there to have at least the same behavior seen on Android.

Hmm, okay, so there is no potential to fix it here, right?

A Exception: DtlsException: Sending failed: Not connected is thrown. I would expect a SocketException Network unreachable. Otherwise behavior seems to be OK.

Hmm, on second thought, for this exception, I think the current behavior does make sense since this exception is only thrown if the connection has not been established or has been closed. Or would you say that there should be a further differentiation?