public override bool TryReceive(TimeSpan timeout, out Message message) { ThrowIfDisposedOrNotOpen(); // FIXME: there seems to be some pipeline or channel- // recycling issues, which could be mostly workarounded // by delaying input receiver. // This place is not ideal, but it covers both loops in // ChannelDispatcher and DuplexClientRuntimeChannel. Thread.Sleep(50); if (timeout <= TimeSpan.Zero) { throw new ArgumentException(String.Format("Timeout value must be positive value. It was {0}", timeout)); } client.ReceiveTimeout = (int)timeout.TotalMilliseconds; message = frame.ReadSizedMessage(); // FIXME: this may not be precise, but connection might be reused for some weird socket state transition (that's what happens). So as a workaround, avoid closing the session by sending EndRecord from this channel at OnClose(). if (message == null) { session = null; return(false); } return(true); }
public override Message Receive(TimeSpan timeout) { ThrowIfDisposedOrNotOpen(); if (timeout <= TimeSpan.Zero) { throw new ArgumentException(String.Format("Timeout value must be positive value. It was {0}", timeout)); } client.ReceiveTimeout = (int)timeout.TotalMilliseconds; return(frame.ReadSizedMessage()); }