You are not logged in.
Hi Arnaud and community,
I'm working on a mission-critical infrastructure using mORMot 2 asynchronous WebSockets and I've encountered a limitation regarding connection health monitoring.
Looking at TWebSocketProcess.ProcessLoopReceived in mormot.net.ws.core.pas, I noticed that fOnBeforeIncomingFrame (and consequently OnBeforeIncomingFrame) is only triggered for focText and focBinary opcodes:
case request.opcode of
focPing:
begin
request.opcode := focPong;
SendFrame(request);
end;
focPong:
; // nothing to do
focText,
focBinary:
if Assigned(fProtocol) then
if (not Assigned(fProtocol.fOnBeforeIncomingFrame)) or
(not fProtocol.fOnBeforeIncomingFrame(self, request)) then
fProtocol.ProcessIncomingFrame(self, request, '');
Was it intentional to exclude control frames (focPing / focPong) from the interceptor?
In high-availability systems, we need to monitor real-time health and latency without injecting application-level heartbeats (to keep the protocol clean). If focPing and focPong were passed to OnBeforeIncomingFrame, we could intercept them for auditing and metrics before the framework handles the automatic response.
Would you consider moving the fOnBeforeIncomingFrame check to the beginning of the ProcessLoopReceived procedure, or at least including these opcodes in the dispatcher?
Something like:
procedure TWebSocketProcess.ProcessLoopReceived(var request: TWebSocketFrame);
begin
if Assigned(fProtocol.fOnBeforeIncomingFrame) then
if fProtocol.fOnBeforeIncomingFrame(self, request) then
exit; // Allow manual override or sniffing
case request.opcode of
// ... rest of the logic
Thank you for this amazing framework!
Offline
Please try with
https://github.com/synopse/mORMot2/commit/8ece4a871
There is a new NotifyAllFrames boolean flag.
Offline
Hi Arnaud,
Thank you very much for the quick fix!
This change is very helpful for monitoring connection health and latency in our infrastructure. I've already tested it and it works perfectly.
Offline