I am using .NET ReportExecutionService to render SSRS reports. We are rendering many reports in rapid fire and we are randomly getting reports that timeout. Somewhere around 1 out of 1400 reports will hang.
When I check the hanging report in ExecutionLog3, I see the report with a status of rsSuccess, and a total time of around 3s. So it looks like the report finishes but the response never gets seen by the render call, and times out after 5 minutes with the following exception:
System.InvalidOperationException: There is an error in XML document (1, 2655). ---> System.Net.WebException: The operation has timed out.
at System.Net.ConnectStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.IO.StreamReader.ReadBuffer(Char[] userBuffer, Int32 userOffset, Int32 desiredChars, Boolean& readToUserBuffer)
at System.IO.StreamReader.Read(Char[] buffer, Int32 index, Int32 count)
at System.Xml.XmlTextReaderImpl.ReadData()
at System.Xml.XmlTextReaderImpl.ParseText(Int32& startPos, Int32& endPos, Int32& outOrChars)
at System.Xml.XmlTextReaderImpl.ParseText()
at System.Xml.XmlTextReaderImpl.ParseElementContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlTextReader.Read()
at System.Xml.XmlReader.ReadElementString()
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read12_ReportParameter(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read17_ExecutionInfo(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read111_SetExecutionParametersResponse()
at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer25.Deserialize(XmlSerializationReader reader)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
--- End of inner exception stack trace ---
If anyone has any suggestions on how to prevent these timeouts I would be glad to try, but I think the easier solution for now is if I can figure out how to set a shorter timeout on the render call. If I can time out and retry the report after 30s that will still give us the performance we need.
Here is my render call. What timeout option do I need to change to make this call fail after 30s?
//tried setting the timeout in the constructor
var rsExec = new rsExecService.ReportExecutionService
{
Url = string.Format("{0}{1}", url, executionServiceUrl), Timeout = 30000
};
//tried setting the timeout before calling render
rsExec.Timeout = 30 * 1000;
results = rsExec.Render(format, deviceInfo, out extension, out mimeType, out encoding, out warnings, out streamIDs);
Related
Event Viewer on my workstation have the following error log:
ERROR NServiceBus.Transports.Msmq.MsmqDequeueStrategy [(null)] - Error in receiving messages.
System.Transactions.TransactionAbortedException: The transaction has aborted. ---> System.Transactions.TransactionManagerCommunicationException: Communication with the underlying transaction manager has failed. ---> System.Runtime.InteropServices.COMException: The Transaction Manager is not available. (Exception from HRESULT: 0x8004D01B)
at System.Transactions.Oletx.IDtcProxyShimFactory.ConnectToProxy(String nodeName, Guid resourceManagerIdentifier, IntPtr managedIdentifier, Boolean& nodeNameMatches, UInt32& whereaboutsSize, CoTaskMemHandle& whereaboutsBuffer, IResourceManagerShim& resourceManagerShim)
at System.Transactions.Oletx.DtcTransactionManager.Initialize()
--- End of inner exception stack trace ---
at System.Transactions.Oletx.OletxTransactionManager.ProxyException(COMException comException)
at System.Transactions.Oletx.DtcTransactionManager.Initialize()
at System.Transactions.Oletx.DtcTransactionManager.get_ProxyShimFactory()
at System.Transactions.Oletx.OletxTransactionManager.CreateTransaction(TransactionOptions properties)
at System.Transactions.TransactionStatePromoted.EnterState(InternalTransaction tx)
--- End of inner exception stack trace ---
at System.Transactions.TransactionStateAborted.CheckForFinishedTransaction(InternalTransaction tx)
at System.Transactions.Transaction.Promote()
at System.Transactions.TransactionInterop.ConvertToOletxTransaction(Transaction transaction)
at System.Transactions.TransactionInterop.GetDtcTransaction(Transaction transaction)
at System.Messaging.MessageQueue.StaleSafeReceiveMessage(UInt32 timeout, Int32 action, MQPROPS properties, NativeOverlapped* overlapped, ReceiveCallback receiveCallback, CursorHandle cursorHandle, IntPtr transaction)
at System.Messaging.MessageQueue.ReceiveCurrent(TimeSpan timeout, Int32 action, CursorHandle cursor, MessagePropertyFilter filter, MessageQueueTransaction internalTransaction, MessageQueueTransactionType transactionType)
at System.Messaging.MessageQueue.Receive(TimeSpan timeout, MessageQueueTransactionType transactionType)
at NServiceBus.Transports.Msmq.MsmqDequeueStrategy.TryReceiveMessage(Func`1 receive, Message& message) in C:\BuildAgent\work\3206e2123f54fce4\src\NServiceBus.Core\Transports\Msmq\MsmqDequeueStrategy.cs:line 332
Facts:
Distributed Transaction Coordinator (DTC) Component Service ==> DTC Enabled
Distributed Transaction Coordinator (DTC) Service ==> Running (referenced to Answered Stack Oveflow Question)
Realtek Audio Universal Service ==> Disabled (as per reference in Fix for 0x8004d01b)
Can anyone recommend a direction on how to check/troubleshoot the cause of the issue?
After long ardous hours, the issue I encountered boils down to permission issue. The services involved in DTC which uses credentials of LocalSystem do not have enough permission and blocked by company-imposed policy implemented on the server.
Unfortunately, I only managed to find an alternative or workaround by using account that have enough permissions to operate and manage the services involved (including custom services).
#gnud - Thanks a lot for your inputs giving me a direction for investigation and that help me continue move forward on my investigation. I appreciate the help. Thanks.
I am trying to load a large amount of data from a server by returning MultiPartContent in the response. However, during the HttpGet method the timeout value I am setting is being ignored. I am trying to set a longer timeout as waiting in this situation is OK.
I have tried various Timeout values between 10 minutes to 2 hours. Realistically the user will only have to wait ~5 minutes the first time they use our app and all other times it will be less.
I have also tried storing a reference of HttpClient to ensure that api.HttpClient isn't re-creating the HttpClient object each time.
var handler = new HttpClientHandler();
var progress = new ProgressMessageHandler(handler);
var api = APIHelpers.GetSession(progress);
progress.HttpReceiveProgress += (e, args) => ProgressChanged.Invoke(e, new SyncEventArgs(GlobalEnums.SyncStage.Downloading, args.ProgressPercentage * 0.01f));
api.HttpClient.Timeout = new TimeSpan(0, 10, 0);
var downloadUri = BuildURI();
var response = await api.HttpClient.GetAsync(downloadUri, HttpCompletionOption.ResponseHeadersRead);
I would expect the application to wait for 10 minutes before throwing a Timeout exception, however the exception is being thrown after 100 seconds (i believe that is the default value?).
Checking the HttpClient.Timeout value after it is set does show that it was set correctly.
The APIHelpers.GetSession() method returns an object of our API with authorisation headers created. The HttpClient object is accessible via an inherited class. This is created by Swashbuckle and Swagger. I have used the api.HttpClient.Timeout = x this way before with success so I don't think this is the issue. It seems to be specific to this scenario in particular.
The exception thrown:
{System.Net.Http.HttpRequestException: An error occurred while sending the request ---> System.Net.WebException: The operation has timed out.
at System.Net.HttpWebRequest.RunWithTimeoutWorker[T] (System.Threading.Tasks.Task`1[TResult] workerTask, System.Int32 timeout, System.Action abort, System.Func`1[TResult] aborted, System.Threading.CancellationTokenSource cts) [0x000f8] in <a1ab7fc4639d4d84af41d68234158b1c>:0
at System.Net.HttpWebRequest.EndGetResponse (System.IAsyncResult asyncResult) [0x00019] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.14.0.114/src/Xamarin.iOS/mcs/class/System/System.Net/HttpWebRequest.cs:1200
at System.Threading.Tasks.TaskFactory`1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func`2[T,TResult] endFunction, System.Action`1[T] endAction, System.Threading.Tasks.Task`1[TResult] promise, System.Boolean requiresSynchronization) [0x0000f] in <939d99b14d934342858948926287beba>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Net.Http.MonoWebRequestHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x003d1] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.14.0.114/src/Xamarin.iOS/mcs/class/System.Net.Http/MonoWebRequestHandler.cs:499
--- End of inner exception stack trace ---
at System.Net.Http.MonoWebRequestHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x0046a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.14.0.114/src/Xamarin.iOS/mcs/class/System.Net.Http/MonoWebRequestHandler.cs:503
at Microsoft.Rest.RetryDelegatingHandler+<>c__DisplayClass11_0.<SendAsync>b__1 () [0x000ad] in <6a6c837cafbb4f1faffaba1ff30ca4e3>:0
at Microsoft.Rest.RetryDelegatingHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00150] in <6a6c837cafbb4f1faffaba1ff30ca4e3>:0
at System.Net.Http.Handlers.ProgressMessageHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00087] in <19af20e76ce04547b3fc150a0f8f2d47>:0
at System.Net.Http.HttpClient.SendAsyncWorker (System.Net.Http.HttpRequestMessage request, System.Net.Http.HttpCompletionOption completionOption, System.Threading.CancellationToken cancellationToken) [0x0009e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.14.0.114/src/Xamarin.iOS/mcs/class/System.Net.Http/System.Net.Http/HttpClient.cs:281
at ...
EDIT:
I'm just adding some additional things I have tried in an attempt to solve this.
I have tried using the DependencyService in Xamarin.Forms to get native HttpClientHandlers and HttpClient objects for each platform where I can set the timeouts per platform instead of relying on Xamarin.Forms to translate it for me. This had the exact same result.
public HttpMessageHandler GetHttpHandler(double timeoutSeconds)
{
var sessionConfig = NSUrlSessionConfiguration.DefaultSessionConfiguration;
sessionConfig.TimeoutIntervalForRequest = timeoutSeconds;
sessionConfig.TimeoutIntervalForResource = timeoutSeconds;
sessionConfig.WaitsForConnectivity = true;
var sessionHandler = new NSUrlSessionHandler(sessionConfig);
return sessionHandler;
}
I have tried creating a new HttpClient object just for this API call but with no luck here either. (This replaces Apihelpers.GetSession() in my code)
There was a known issue in both Xamarin.iOS and Xamarin.Android that HttpClient.Timeout values greater than 100 seconds are ignored. This is because the underlying native http clients have a timeout set to 100 seconds, so this times out before the .NET HttpClient times out when the HttpClient.Timeout value > 100 seconds. This should be fixed in all of the latest stable versions, so make sure you are updated. If you are using Visual Studio 2017, you won't have the fix, you will need to get VS 2019 for the fixes.
Had the same issue in my Xamarin Android project. Resolved it by changing HttpClient implementation to Android in the Project properties as below:
We have a web application which uses Microsoft.Web.Redis.RedisSessionStateProvider as the session state provider. We've had no problems with this until recently when suddenly the application is reporting a large number of exceptions as detailed below.
The message suggests some kind of timeout. But I've no idea how to resolve this. The application is an instance of Kentico CMS and we haven't customised its session caching mechanism in any way.
Main exception:
Message:
Exception of type 'System.Web.HttpException' was thrown.
Stack Trace:
at System.Web.HttpAsyncResult.End()
at System.Web.HttpApplication.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar)
Inner exception:
Message:
Timeout performing EVAL, inst: 1, mgr: Inactive, err: never, queue: 0, qu: 0, qs: 0, qc: 0, wr: 0, wq: 0, in: 0, ar: 0, IOCP: (Busy=0,Free=1000,Min=2,Max=1000), WORKER: (Busy=3,Free=32764,Min=2,Max=32767), clientName: KSCOMAZUATWEB2
Stack Trace:
at StackExchange.Redis.ConnectionMultiplexer.ExecuteSyncImpl[T](Message message, ResultProcessor`1 processor, ServerEndPoint server) in c:\TeamCity\buildAgent\work\3ae0647004edff78\StackExchange.Redis\StackExchange\Redis\ConnectionMultiplexer.cs:line 1927
at StackExchange.Redis.RedisBase.ExecuteSync[T](Message message, ResultProcessor`1 processor, ServerEndPoint server) in c:\TeamCity\buildAgent\work\3ae0647004edff78\StackExchange.Redis\StackExchange\Redis\RedisBase.cs:line 80
at StackExchange.Redis.RedisDatabase.ScriptEvaluate(String script, RedisKey[] keys, RedisValue[] values, CommandFlags flags) in c:\TeamCity\buildAgent\work\3ae0647004edff78\StackExchange.Redis\StackExchange\Redis\RedisDatabase.cs:line 866
at Microsoft.Web.Redis.StackExchangeClientConnection.<>c__DisplayClass4.<Eval>b__3() in d:\TeamCityBuildAgent\work\f55792526e6d9089\src\Shared\StackExchangeClientConnection.cs:line 113
at Microsoft.Web.Redis.StackExchangeClientConnection.RetryForScriptNotFound(Func`1 redisOperation) in d:\TeamCityBuildAgent\work\f55792526e6d9089\src\Shared\StackExchangeClientConnection.cs:line 129
at Microsoft.Web.Redis.StackExchangeClientConnection.RetryLogic(Func`1 redisOperation) in d:\TeamCityBuildAgent\work\f55792526e6d9089\src\Shared\StackExchangeClientConnection.cs:line 155
at Microsoft.Web.Redis.StackExchangeClientConnection.Eval(String script, String[] keyArgs, Object[] valueArgs) in d:\TeamCityBuildAgent\work\f55792526e6d9089\src\Shared\StackExchangeClientConnection.cs:line 113
at Microsoft.Web.Redis.RedisConnectionWrapper.TryTakeWriteLockAndGetData(DateTime lockTime, Int32 lockTimeout, Object& lockId, ISessionStateItemCollection& data, Int32& sessionTimeout) in d:\TeamCityBuildAgent\work\f55792526e6d9089\src\RedisSessionStateProvider\RedisConnectionWrapper.cs:line 182
at Microsoft.Web.Redis.RedisSessionStateProvider.GetItemFromSessionStore(Boolean isWriteLockRequired, HttpContext context, String id, Boolean& locked, TimeSpan& lockAge, Object& lockId, SessionStateActions& actions) in d:\TeamCityBuildAgent\work\f55792526e6d9089\src\RedisSessionStateProvider\RedisSessionStateProvider.cs:line 272
at Microsoft.Web.Redis.RedisSessionStateProvider.GetItemExclusive(HttpContext context, String id, Boolean& locked, TimeSpan& lockAge, Object& lockId, SessionStateActions& actions) in d:\TeamCityBuildAgent\work\f55792526e6d9089\src\RedisSessionStateProvider\RedisSessionStateProvider.cs:line 190
at System.Web.SessionState.SessionStateModule.GetSessionStateItem()
at System.Web.SessionState.SessionStateModule.PollLockedSessionCallback(Object state)
After experiencing the same issue and having read various posts on setting min & max thread values etc, it transpired that the issue was with the subscription tier.
C1 basic (£35/GBP mth) boasts a 1gb cache, 1000 concurrent connections which are exactly the same headline figures as the C1 Standard tier (£95GBP/Mth).
It's a natural assumption that when you only require a few MB of cache and have only 50 concurrent sessions active at any point, that the C! basic would be adequate, if not overkill.
The difference seems to be that C1 Basic works, if you have 10 or less concurrent users on your website.
In fairness, it is mentioned in the fine print that the basic is only suitable for development and testing environments.
I was just working through this on a client site and what helped me was to add this to the connection string of your provider:
throwOnError="true" retryTimeoutInMilliseconds="500"
What I learned is sometimes there is a latency issue and if it doesn't resolve fast enough the default is to just "quit". So adding this allows it to continue to retry.
Your string might look like this
<add name="MySessionStateStore" throwOnError="true" retryTimeoutInMilliseconds="500" type="Microsoft.Web.Redis.RedisSessionStateProvider" host="mysite-prod.redis.cache.windows.net" accessKey="mykey" ssl="true" />
I have a NancyFX API, and when one of the endpoints is hit, I need to kick of a longer running asynchonous task that's decoupled from the endpoint itself. So I'm trying to use a Azure Service Bus queue.
I'm successfully writing a message to the queue when the NancyFX endpoint is hit. I can also successfully subscribe and read from the queue from something other than NancyFX (I tested from Linqpad).
However, if I try to subscribe from the NancyFX app, I get a timeout exception within a second or two from starting the app. I'm doing this in another thread which is kicked off from the NancyFX Bootstrapper.ApplicationStartup override.
I'm unsure why this would be different than doing it not in the NancyFX app. I can't see anything of relevance in the web.config file.
Below is the code I'm using to subscribe to the queue ...
var tokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider("Main", AccessKey);
var factory = await MessagingFactory.CreateAsync("sb://myapp.servicebus.windows.net", tokenProvider);
var receiver = await factory.CreateMessageReceiverAsync("MyQueue");
receiver.OnMessage(bm =>
{
// Do something here
}, new OnMessageOptions
{
MaxConcurrentCalls = 1,
});
Below is the exception ...
System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]: A timeout has occurred during the operation. b6b8e25a-714f-4f55-8a79-91e390f47a96_G25 (Fault Detail is equal to An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.TimeoutException: A timeout has occurred during the operation.
).
And here is the callstack when I caught it in the debugger ...
Microsoft.ServiceBus.dll!Microsoft.ServiceBus.Messaging.Sbmp.DuplexRequestBindingElement.DuplexRequestSessionChannel.ThrowIfFaultMessage(System.ServiceModel.Channels.Message wcfMessage) Line 463 C#
Microsoft.ServiceBus.dll!Microsoft.ServiceBus.Messaging.Sbmp.DuplexRequestBindingElement.DuplexRequestSessionChannel.HandleMessageReceived(System.IAsyncResult result) Line 313 C#
Microsoft.ServiceBus.dll!Microsoft.ServiceBus.Messaging.Sbmp.DuplexRequestBindingElement.DuplexRequestSessionChannel.OnMessageReceived(System.IAsyncResult result) Line 381 C#
System.ServiceModel.Internals.dll!System.Runtime.AsyncResult.Complete(bool completedSynchronously) Unknown
System.ServiceModel.dll!System.ServiceModel.Channels.TransportDuplexSessionChannel.TryReceiveAsyncResult.OnReceive(System.IAsyncResult result) Unknown
System.ServiceModel.Internals.dll!System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(System.IAsyncResult result) Unknown
System.ServiceModel.Internals.dll!System.Runtime.AsyncResult.Complete(bool completedSynchronously) Unknown
System.ServiceModel.dll!System.ServiceModel.Channels.SynchronizedMessageSource.ReceiveAsyncResult.OnReceiveComplete(object state) Unknown
System.ServiceModel.dll!System.ServiceModel.Channels.SessionConnectionReader.OnAsyncReadComplete(object state) Unknown
System.ServiceModel.Internals.dll!System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(System.IAsyncResult result) Unknown
System.dll!System.Net.LazyAsyncResult.Complete(System.IntPtr userToken) Unknown
System.dll!System.Net.LazyAsyncResult.ProtectedInvokeCallback(object result, System.IntPtr userToken) Unknown
System.dll!System.Net.Security._SslStream.ProcessFrameBody(int readBytes, byte[] buffer, int offset, int count, System.Net.AsyncProtocolRequest asyncRequest) Unknown
System.dll!System.Net.Security._SslStream.ReadFrameCallback(System.Net.AsyncProtocolRequest asyncRequest) Unknown
System.dll!System.Net.AsyncProtocolRequest.CompleteRequest(int result) Unknown
System.dll!System.Net.FixedSizeReader.CheckCompletionBeforeNextRead(int bytes) Unknown
System.dll!System.Net.FixedSizeReader.ReadCallback(System.IAsyncResult transportResult) Unknown
System.ServiceModel.Internals.dll!System.Runtime.AsyncResult.Complete(bool completedSynchronously) Unknown
System.ServiceModel.dll!System.ServiceModel.Channels.ConnectionStream.IOAsyncResult.OnAsyncIOComplete(object state) Unknown
System.dll!System.Net.Sockets.SocketAsyncEventArgs.OnCompleted(System.Net.Sockets.SocketAsyncEventArgs e) Unknown
System.dll!System.Net.Sockets.SocketAsyncEventArgs.FinishOperationSuccess(System.Net.Sockets.SocketError socketError, int bytesTransferred, System.Net.Sockets.SocketFlags flags) Unknown
System.dll!System.Net.Sockets.SocketAsyncEventArgs.CompletionPortCallback(uint errorCode, uint numBytes, System.Threading.NativeOverlapped* nativeOverlapped) Unknown
mscorlib.dll!System.Threading._IOCompletionCallback.PerformIOCompletionCallback(uint errorCode, uint numBytes, System.Threading.NativeOverlapped* pOVERLAP) Unknown
[Native to Managed Transition]
The exception you got is an indication of the client not being able to go past ASB gateway to talk to the backend. You could use the provided tracking ID (b6b8e25a-714f-4f55-8a79-91e390f47a96_G25) to open a support case. In case that exception persists, try a different namespace to see if that rules it out.
To start off explaining, I have a model called VitalSign and one called VitalSignValues.
In my VitalSign model I have this code:
[ForeignKey("IdVitalSign")]
public virtual ICollection<VitalSignValue> VitalSignValues { get; set; }
In my VitalSignValue model:
public Guid IdVitalSign { get; set; }
And I got a default manager with basic functions like getAll(), ...
The project contains multiple web services and they all work fine, except for this one (VitalSignService). When I run the service, even with the WCF Test Client and I test the getAll function, it works.
The problem is that the getAll function only works like once, when I try to call the function again I suddenly get this error:
An error occurred while receiving the HTTP response to http://localhost/webservice/VitalSignService.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.
I tried to check the trace logs, but for some reason the only information it gives me is:
ASP.Net hosted compilation
AppDomain unloading
Here is the error log (although it doesn't really contain good information for me)
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at IVitalSignService.GetAllVitalSigns()
at VitalSignServiceClient.GetAllVitalSigns()
Inner Exception:
The underlying connection was closed: An unexpected error occurred on a receive.
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
Inner Exception:
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
Inner Exception:
An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
EDIT:
Here is some more information:
In my application, I call this function:
var client = new VitalSignServiceClient();
_vitalSigns = client.GetAllVitalSignsWithValues().ToList();
client.Close();
Inside of my service, I got this function:
public ICollection<VitalSign> GetAllVitalSignsWithValues()
{
return _vitalSignManager.GetAll("VitalSignValues");
}
In my generic manager, this happens:
public ICollection<TObject> GetAll(params string[] navigationProperties)
{
var query = Context.Set<TObject>().AsQueryable();
foreach (string navigationProperty in navigationProperties)
query = query.Include(navigationProperty);
var list = query.ToList<TObject>();
return list;
}
When I try to find the problem through debugging, it does go into the service, into the generic manager and it does get the VitalSigns, it's just the moment where the client retrieves the data from the web service that the error occurs and everything fails.
Also remember that all of this actually works (but only 1 out of 10 times, so probably only when the server refreshed it or something)
SOLVED: Removed the "virtual" in front of the IList
I don't like the way you're closing/disposing your WCF proxies and EF contexts. Looking for trouble there. Look into "using" like below. I would also recommend you don't use a static EF context. Again looking for trouble by doing this. (LinqToSql declare and instantiate DataContext best practice?). Third, I know it's tempting to make a generic repository that does everything but this ends up being more work than it's worth. For testing, performance and maintainability purposes, make your API calls specific.
Try:
using(var client = new VitalSignServiceClient()
{
_vitalSigns = client.GetAllVitalSignsWithValues().ToList();
}
public ICollection<VitalSign> GetAllVitalSigns()
{
using(ctx = new YourContext())
{
// do stuff
}
}