void ProcessClientRequests(Func <RequestMessage, ResponseMessage> incomingRequestProcessor) { while (true) { var request = stream.Receive <RequestMessage>(); if (request == null) { continue; } var response = InvokeAndWrapAnyExceptions(request, incomingRequestProcessor); stream.Send(response); if (!stream.ExpectNextOrEnd()) { break; } stream.SendProceed(); } }
void ProcessClientRequests(Func <RequestMessage, ResponseMessage> incomingRequestProcessor) { while (acceptClientRequests) { var request = stream.Receive <RequestMessage>(); if (request == null || !acceptClientRequests) { return; } var response = InvokeAndWrapAnyExceptions(request, incomingRequestProcessor); if (!acceptClientRequests) { return; } stream.Send(response); try { if (!acceptClientRequests || !stream.ExpectNextOrEnd()) { return; } } catch (Exception ex) when(ex.IsSocketConnectionTimeout()) { // We get socket timeout on the Listening side (a Listening Tentacle in Octopus use) as part of normal operation // if we don't hear from the other end within our TcpRx Timeout. log.Write(EventType.Diagnostic, "No messages received from client for timeout period. Connection closed and will be re-opened when required"); return; } stream.SendProceed(); } }