SmingHub / Sming

Sming - powerful open source framework simplifying the creation of embedded C++ applications.
https://sming.readthedocs.io
GNU Lesser General Public License v3.0
1.45k stars 349 forks source link

Handling TCP connection errors #2829

Open mikee47 opened 1 week ago

mikee47 commented 1 week ago

There is an ongoing issue with the apparent lack of response when HTTP connections fail, such as with invalid URLs (issue #1937).

PR #1939 was a simple attempt to address this problem, but I'm closing that because this issue requires scoping out properly first and applies to all types of TCP connections, not just HTTP.

When a HTTP request is issued a completed delgate is supplied, which receives a boolean successful parameter. This parameter is false if HTTP parsing fails or the remote connection returns an HTTP error code.

If, when sending the request, a failure occurs in the connection process then the callback is never invoked. This can happen if:

And probabaly others. Issues are:

My feeling is that invoking the HttpRequest completion callback is not the correct approach here since a failure (successful=false) should only relate to the response from the remote server. Here, the request hasn't actually completed and is still in the queue.

This suggests that a new API for catching such errors would be useful for an application. We'd need to: