I have a windows application (actually an Outlook addin) that calls an asmx web service (yes, it's legacy, but the company is reluctant to move away from it & re-develop everything...) to get some data. The return value is a DataTable. I am calling the web service by adding is as a web service reference.
This has been working correctly for all clients, but recently one client reported an issue where calling the web service throws the following errors (on two separate calls):
Exception Type: InvalidOperationException
Exception Message: There is an error in XML document (23, 93530).
Inner Ex Type: IOException
Inner Ex Message: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
StackTrace: at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) at
Exception Type: InvalidOperationException
Exception Message: There is an error in XML document (4426, 32).
Inner Ex Type: IOException
Inner Ex Message: The operation has timed out.
StackTrace: at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) at
I am able to rule out that my application is generating the timeout as I am setting the web service class' TimeOut property to 2hrs before the call, and the next request has come through to the server in about 20-30 minutes.
Going through the IIS log, all the requests that have failed for the client have a http status of 200, but also a win32-status of 995.
I have been trying to replicate this error and get the reason why it is occurring without any success for the better part of the last 3 days (I need to find the exact reason - company policy :( :P). I need to know why this occurs and what is the solution or best work-around for this issue.
I have also posted this on the MSDN forum here
Can anyone help me with this? Any help is greatly appreciated. Thanks!
Cheers!
you need to check to see if your hitting a connection limit ask the servers closing it
as the other party to check web.config
<system.net>
<connectionManagement>
<add address="*" maxconnection="40"/>
</connectionManagement>
</system.net>
Related
I have WCF service which is returning data of 6500 rows of data list. When I am trying to retrieve that data from service it is throwing error like -
An error occurred while receiving the HTTP response to http://myservice.myDomain.com/Services/myTestService.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 have tried to increase the time in configuration still the issue persists.
in Trace I am getting same like below :
Trace log it is showing the error like the same below :
An error occurred while receiving the HTTP response to http://myservice.myDomain.com/Services/myTestService.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.
stack Trace:
System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
The first thing you should do is set up and start using the service trace viewer tool, this will allow you to drill further down into the specific call and find out exactly what the error is.
http://msdn.microsoft.com/en-us/library/ms732023(v=vs.110).aspx
http://msdn.microsoft.com/en-us/library/ms751526(v=vs.110).aspx
Once you get this up and running you can run your code and then view the specific error you are getting, this will quite often be able to tell you what field or object is causing the error. The error you are getting in your debug is just a sign that something failed, you need to use a trace viewer to see what.
Without the actual error from the logging, it's hard to say exactly what is causing the error, however the most common cause is a lack of proper serialization on the object being returned by the service.
EDIT:
Looking at your stack trace it looks like you may have a cyclical reference somewhere in the object being returned, you'll need to add the IsReference=true flag to the offending objects http://msdn.microsoft.com/en-us/library/system.runtime.serialization.datacontractattribute.isreference(v=vs.95).aspx
If you can post the code for the object(s) being returned I may be able to better point you at the issue.
EDIT 2: Also, if you can post the XML for the exception in the svclog file (copy the contents of the XML tabl in the Service trace viewer), that would shed further light also.
When I make POST and PUT requests to my ServiceStack services (running standalone with an HTTP listener at the moment) I sometimes find that the request will work, and sometimes my client (HTTPie) will hang. After a while I'll see some info in the Output window in Visual Studio:-
A first chance exception of type 'System.Net.HttpListenerException' occurred in System.dll
A first chance exception of type 'System.Runtime.Serialization.SerializationException' occurred in ServiceStack.dll
A first chance exception of type 'System.Net.HttpListenerException' occurred in System.dll
A first chance exception of type 'System.Net.HttpListenerException' occurred in ServiceStack.dll
A first chance exception of type 'System.Net.HttpListenerException' occurred in ServiceStack.dll
A first chance exception of type 'System.Runtime.Serialization.SerializationException' occurred in ServiceStack.dll
A first chance exception of type 'System.ObjectDisposedException' occurred in System.dll
I managed to enable the built-in logging in ServiceStack and it gave more details:-
ERROR: Error occured while Processing Request: Could not deserialize 'application/json; charset=utf-8'
request using WebServices.Dto.Country'
Error: System.Net.HttpListenerException (0x80004005): The I/O operation has been aborted because of either
a thread exit or an application request
at System.Net.HttpRequestStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.IO.StreamReader.ReadBuffer()
at System.IO.StreamReader.ReadToEnd()
at ServiceStack.Text.JsonSerializer.DeserializeFromStream(Type type, Stream stream) in C:\src\ServiceStack.Text\
src\ServiceStack.Text\JsonSerializer.cs:line 164
at ServiceStack.ServiceModel.Serialization.JsonDataContractDeserializer.DeserializeFromStream(Type type, Stream
stream) in C:\src\ServiceStack\src\ServiceStack.Common\ServiceModel\Serialization\JsonDataContractDeserializer.cs:line 86
at ServiceStack.WebHost.Endpoints.Support.EndpointHandlerBase.CreateContentTypeRequest(IHttpRequest httpReq,
Type requestType, String contentType) in C:\src\ServiceStack\src\ServiceStack\WebHost.Endpoints\Support\
EndpointHandlerBase.cs:line 100,
Exception: Could not deserialize 'application/json; charset=utf-8' request using WebServices.Dto.Country'
Error: System.Net.HttpListenerException (0x80004005): The I/O operation has been aborted because of either a thread
exit or an application request
at System.Net.HttpRequestStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.IO.StreamReader.ReadBuffer()
at System.IO.StreamReader.ReadToEnd()
at ServiceStack.Text.JsonSerializer.DeserializeFromStream(Type type, Stream stream) in C:\src\ServiceStack.Text\src\
ServiceStack.Text\JsonSerializer.cs:line 164
at ServiceStack.ServiceModel.Serialization.JsonDataContractDeserializer.DeserializeFromStream(Type type, Stream
stream) in C:\src\ServiceStack\src\ServiceStack.Common\ServiceModel\Serialization\JsonDataContractDeserializer.cs:line 86
at ServiceStack.WebHost.Endpoints.Support.EndpointHandlerBase.CreateContentTypeRequest(IHttpRequest httpReq,
Type requestType, String contentType) in C:\src\ServiceStack\src\ServiceStack\WebHost.Endpoints\Support\EndpointHandlerBase.cs:line 100
ERROR: Could not WriteTextToResponse: An operation was attempted on a nonexistent network connection, Exception:
An operation was attempted on a nonexistent network connection
ERROR: Could not WriteTextToResponse: An operation was attempted on a nonexistent network connection, Exception:
An operation was attempted on a nonexistent network connection
INFO: Failed to write error to response: {0}, Exception: An operation was attempted on a nonexistent network connection
I am making my test requests like this:-
http --json post "http://localhost:1337/countries/" DefaultHouse_Id=2 Name=Denmark
This exact attempt works some time and fails others.
I'm using the latest ServiceStack from NuGet with .NET4 and VS 2010.
It appears that the request does not reach my own code at all.
Does anyone know what could cause this, or how I can debug it?
Edit: Not sure if it's related or not, but sometimes I also get this:-
{
"ResponseStatus":{
"ErrorCode":"TypeLoadException",
"Message":"Could not load type 'ServiceStack.ServiceInterface.HttpRequestApplyToExtensions' from assembly 'ServiceStack.ServiceInterface, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.",
"StackTrace":" at RulesLayer.AuditFilterAttribute.Execute(IHttpRequest req, IHttpResponse res, Object requestDto)\n at ServiceStack.ServiceInterface.RequestFilterAttribute.RequestFilter(IHttpRequest req, IHttpResponse res, Object requestDto) in C:\\src\\ServiceStack\\src\\ServiceStack.ServiceInterface\\RequestFilterAttribute.cs:line 41\n at ServiceStack.WebHost.Endpoints.EndpointHost.ApplyRequestFilters(IHttpRequest httpReq, IHttpResponse httpRes, Object requestDto) in C:\\src\\ServiceStack\\src\\ServiceStack\\WebHost.Endpoints\\EndpointHost.cs:line 303\n at ServiceStack.WebHost.Endpoints.RestHandler.ProcessRequest(IHttpRequest httpReq, IHttpResponse httpRes, String operationName) in C:\\src\\ServiceStack\\src\\ServiceStack\\WebHost.Endpoints\\RestHandler.cs:line 63"
}
}
It appears AVG Anti-Virus Business was the culprit. I knew I hated anti-virus software for a reason!
I discovered that the code worked fine on another machine, which told me that it was something specific to my dev box setup. I tried stripping the machine back to bare minimum, removing unused software, VS extensions, plugins etc. I tried both IIS Express and self-hosted modes for ServiceStack. I tried moving my code out of Dropbox. Nothing made any difference.
When I finally disabled AVG, the problem just vanished and several hours later it's still working perfectly.
To debug, nothing beats downloading the project source code and debugging the framework source code itself. I recommend trying to replicate this behavior in an integration test so we can find out what's causing it. See ServiceStack's http listener integration tests for examples on how to do this.
To enable logging in ServiceStack you just need set the log factory to be the provider of your choice before you start/initialize the AppHost.
LogManager.LogFactory = new ConsoleLogFactory(typeof(Program));
Sorry if the Title is a little vague but the truth is I do not understand my problem, I have never come across this before and I havent done anything out of the Ordinary.
Right I have a basic Silverlight 4 Application using the Business Application Template. I have also created a WCF Service Application Project which is used to simply return an Observable collection for some entries in my Database,
I published this to my Local computer which I then referenced in my SL4 app and I get this exception
[System.ServiceModel.CommunicationException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound.
at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass5. <EndGetResponse>b__4(Object sendState)
at System.Net.Browser.AsyncHelper.<>c__DisplayClass4.<BeginOnUI>b__0(Object sendState)
--- End of inner exception stack trace ---
at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest. CompleteGetResponse(IAsyncResult result)
--- End of inner exception stack trace ---
at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
at System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result)
at RMServiceRIA.rService.Service1Client.Service1ClientChannel.EndgetBuildings(IAsyncResult result)
at RMServiceRIA.rService.Service1Client.RMServiceRIA.rService.IService1.EndgetBuildings(IAsync Result result)
at RMServiceRIA.rService.Service1Client.OnEndgetBuildings(IAsyncResult result)
at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)}
I have got a clientaccess policy and crossdomain policy which for the purpose of testing is set to allow anything access,
Client Access Policy
Cross Domain
any ideas on how to fix this problem, I debugged my WCF Service and it receives the call, the method executed reaches its return statement, yet my SL4 never even receives the result, as soon as my WCF service has the result I get an exception thrown within my SL4 app, to me it just seems that the connection gets closed but I dont know and I have tried to research but where do you start with something you dont fully understand? I found many people with the same sort of error message but WCF is so damn cryptic... I did try and enable the debugging information inside of my webconfig. I have also tried to host the WCF service on my Web server but no luck, I have several WCF Services running on that with a similar set up so I am unsure why this isnt working
Web Config for WCF Service
client config
Thanks for having a look, and if you need any more info just ask I'll be happy to provide you with it,
Your best bet is to turn on WCF Tracing so you can see what is going on.
http://software.intel.com/en-us/blogs/2010/02/03/adventures-with-silverlight-and-wcf-the-remote-server-returned-an-error-notfound/
Most likely there is an issue with serializing something. Not found is just the Silverlight version of a 500 error.
We have a WinForms application (.NET 4.0/C#) that accesses several web services. We deployed to a client who has some proxy feature on their firewall (no proxy settings in Internet Options on the client machine, but it definitely IS a proxy).
The problem is, our WinForms app will fail on the first web service call. The error information isn't very useful but it's clear that it's unable to call the web service methods. The weird part is, once we put the web service (asmx) URL in Internet Explorer on that client machine, it works just fine for several days. It's as if IE is causing the router to cache some of the routing information.
Has anyone else experienced this? Is there a simple fix that we could implement?
Thank you!
Here is the Exception information:
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Net.WebException
Stack:
Server stack trace:
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at AutoUpdater.Module.WebService.AutoUpdaterWebService.AutoUpdater.ValidateInstallKey(String installKey, String computerIdentifier)
at AutoUpdater.Module.WebService.Config.ValidateInstallKey()
at AutoUpdater.Module.RemoteService.ValidateInstallKey()
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(System.Runtime.Remoting.Messaging.IMessage, System.Runtime.Remoting.Messaging.IMessage)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(System.Runtime.Remoting.Proxies.MessageData ByRef, Int32)
at AutoUpdater.Foundation.Interfaces.IRemoteService.ValidateInstallKey()
at AutoUpdater.UpdateForm..ctor()
at AutoUpdater.Program.Main()
I am trying to download a zip file on my server by doing
WebClient.DownloadFileAsync(new Uri(DownloadLink),
Path.GetFileName(DownloadLink));
I have events linked to download completed and progress changed and when the download gets to 99%, it stops. So I give it a minute and then it gives me an exception:
System.Net.WebException: An exception occurred during a WebClient request. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)
--- End of inner exception stack trace ---
at System.Net.ConnectStream.EndRead(IAsyncResult asyncResult)
at System.Net.WebClient.DownloadBitsReadCallbackState(DownloadBitsState state, IAsyncResult result)
--- End of inner exception stack trace ---
I am stumped. I can download the file fine on my browser.
I don't have a direct answer to your question, but there are a few things I'd try in order to see if I could identify the problem.
First, get rid of the asynchronous call and just call DownloadFile. Does the error still occur?
Call DownloadData to get the data in a byte array, and then save the file.
If either or both of the above work, then I'd say there's something wrong with your DownloadDataCompleted event handler, although why that'd throw a WebException is beyond me.
Oh, one other thing: are you sure that Path.GetFileName(DownloadLink) is returning a valid file name, and that you have the necessary permissions to write the file in the current directory?
You will get a WebException if DownloadLink returns an error like 404. Put a breakpoint in and check the actual path going into the method.
Edit: If DownloadLink is a url string check if you are escaping '/'. Try #"..."