@chrishamm
I am not using duet3 in SBC mode, I am developing my own custom controller and want to remove layers of complexity, if possible.
Looking at the code, keep-alive
is implemented, at least partially, in
src/Networking/HttpResponder.cpp
I have found several lines where Connection
is set to close
and other lines where a keepOpen
variable is used to set close
or keep-alive
.
I also found a line where the socket is kept open
Commit(keepOpen ? ResponderState::reading : ResponderState::free, false);
And other places close it straight away
Commit(ResponderState::free, false);
//or
Commit();
In GetJsonResponse
I have noticed, keepOpen
is set to false
and never changes.
bool HttpResponder::GetJsonResponse(const char *_ecv_array request, OutputBuffer *&response, bool& keepOpen) noexcept
{
keepOpen = false; // assume we don't want to persist the connection
...
To me all this looks like 90% of the keep alive support is already in place?
I would try to finish the implementation myself.
I could check for the existence of an extra custom header and, if present, keep the socket open. This would prevent browsers and other connections that send keep-alive
from actually keeping the socket open.
The HttpReceiveTimeout
is set to 2 seconds, so the socket will close automatically when not used.
I only need 1 connection for my project, so I could also try to implement that only 1 socket can be kept alive concurrently, the rest is ignored.
Do you know of any other pitfalls?
Keep-alive apparently has been tested in the past?
Thanks
Cheers
Gerd