internal async Task<FetchResponse> Fetch(FetchRequest req, Connection conn) { _log.Debug("Sending FetchRequest to broker {1}. Request: {0}", req, conn); if (_etw.IsEnabled()) _etw.ProtocolFetchRequest(req.ToString()); // Detect disconnected server. Wait no less than 5sec. // If wait time exceed wait time + 3sec, consider it a timeout too //var timeout = Math.Max(5000, req.MaxWaitTime + 3000); //var cancel = new CancellationTokenSource(timeout); var tcp = await conn.GetClientAsync(); var response = await conn.Correlation.SendAndCorrelateAsync( id => Serializer.Serialize(req, id), Serializer.DeserializeFetchResponse, tcp, /*cancel.Token*/ CancellationToken.None); if (_etw.IsEnabled()) _etw.ProtocolFetchResponse(response.ToString()); return response; }