An existing connection was forcibly closed by the remote host on WCF - wcf

We are getting following issue in our Production environment only. rest of environments its working fine.
we checked various links on stackoverflow but nothing worked.
tried increasing `
<httpRuntime maxRequestLength="2147483647" />
increased timeout
put tracing, but even that not showing any specific issue
[SocketException (0x2746): An existing connection was forcibly closed by the remote host]
System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) +245
[IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.]
System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) +7867549
System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size) +22
System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead) +408
[WebException: The underlying connection was closed: An unexpected error occurred on a receive.]
System.Net.HttpWebRequest.GetResponse() +7870788
System.ServiceModel.Channels.HttpChannelRequest.WaitForReply(TimeSpan timeout) +99
[CommunicationException: An error occurred while receiving the HTTP response to http://myservice/Service.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.]
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +4728419
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +1725
MyService.ISSO.ProcessRequest(SSORequest request) +0

"Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host."
This error could be generated because of Group Policy Settings. Try connecting to Analysis Service using SQL Management Studio, if error persist try to elevate the user privilages.

Related

Why would S3 bucket connection require EC2 access when connecting from a remote app

I have an .NET app that upload files to S3 bucket. The app hosted in a server in a closed network, so we created firewall rule to whitelist outbound traffic to S3(AP-Southeast-2) IP ranges. We noticed that there are intermittent connection issues and throwing following exception;
Amazon.Runtime.AmazonServiceException: A WebException with status SendFailure was thrown. ---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> 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.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
We no longer get intermittent connection issue when we allow all outbound traffic. But we noticed that there are outbound traffic to EC2 IP range as well.
Question: Why would S3 bucket connection require EC2 access when connecting from a remote app?

Cannot connect to rabbitmq

Can not connect to internal Rabbit MQ instance. Receive following error:
The AMQP operation was interrupted: AMQP close-reason, initiated by Library, code=541, text="Unexpected Exception", classId=0, methodId=0, cause=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.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at RabbitMQ.Client.Impl.Frame.ReadFrom(NetworkBinaryReader reader)
at RabbitMQ.Client.Impl.SocketFrameHandler_0_9.ReadFrame()
at RabbitMQ.Client.Impl.ConnectionBase.MainLoopIteration()
at RabbitMQ.Client.Impl.ConnectionBase.MainLoop()
Could it be that my firewall is blocking required port?
Ok, problem solved. Not sure if would be helpful for someone, but: there was old MassTransit (RabbitMQ client) version, which required to set in URI not just vhost, but also queue address.

net.pipe endpoint is not connectable from client application

I am facing issue related to net.pipe end point of my WCF Service. I have configured required server roles (Application & Web Roles) and features (Windows Activation) in a Windows 2008 R2 machine. I created a sample wcf service with net.tcp, net.pipe and http endpoints and hosted it in IIS. I have enabled required binding in site level as well as Web Application level also. net.tcp & http endpoints are working fine. But getting error for net.pipe endpoint as mentioned below
System.ServiceModel.EndpointNotFoundException: There was no endpoint listening at net.pipe://localhost/MyWCFService/Service1.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
Server stack trace:
at System.ServiceModel.Channels.ConnectionUpgradeHelper.DecodeFramingFault(ClientFramingDecoder decoder, IConnection connection, Uri via, String contentType, TimeoutHelper& timeoutHelper)
at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.SendPreamble(IConnection connection, ArraySegment`1 preamble, TimeoutHelper& timeoutHelper)
at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.DuplexConnectionPoolHelper.AcceptPooledConnection(IConnection connection, TimeoutHelper& timeoutHelper)
at System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout)
at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel channel, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade)
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 NetPipeValidation.ServiceReference1.IService1.GetData(Int32 value)
at NetPipeValidation.ServiceReference1.Service1Client.GetData(Int32 value)
at NetPipeValidation.Form1.button1_Click(Object sender, EventArgs e)
My initial suspect was net.pipe protocol is not properly activated. So validated all required windows services are running correctly (WAS, Net.Pipe Adaptar, Net.Tcp Adaptar). I also checked on SMSvcHost.exe.config file and made sure it has right configuration.
Since all services are running, I enabled performance counter and checked whether my net.pipe registration is sucessful. Regitrations Active for net.pipe and Uris Registered for Net.pipe has count as 1. With these counter values, I assuming my endpoint is properly configured and valid from server side perspective.
For some reason, end point is not reachable from client side. Is there any other validation I need to do in the machine?
net.pipe is intended for x-process calls, not x-machine calls. If you're crossing machine boundaries, you use http and/or net.tcp. If you're client and service are on the same machine, then you should use net.pipe.

Problem with windows service

I have wcf service that twice a minute check %programdata%/MYAPP folder and send all xml-files from this directory to sharepoint site. But i have some problem with this service (description from Event Viewer):
System.ServiceModel.EndpointNotFoundException: There was no endpoint listening at https://localhost:44300/DataService.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:44300
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
at System.Net.HttpWebRequest.GetRequestStream()
at System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStream()
--- End of inner exception stack trace ---
Server stack trace:
at System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStream()
at System.ServiceModel.Channels.HttpOutput.Send(TimeSpan timeout)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.SendRequest(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.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 IncidentReportAgent.IRS3DataService.IDataService.UploadReport(Stream reportBinary)
at IncidentReportAgent.IncidentReportAgentService.ProcessFile(String fileName)
Service work only if i start service from VS2010 (project->debug->start new instance).
"Service work only if i start service from VS2010 (project->debug->start new instance)."
Sounds to me like you haven't actually hosted the service anywhere outside of Visual Studio. Based on the service endpoint address it's looking for, it looks like your intent is to host under IIS.
You'll need to configure IIS with a virtual directory/application for the service.
How to: Host a WCF Service in IIS
The error message says that it cannot find the service at https://localhost:44300/DataService.svc
This is probably the address where VS runs the service.
If you have installed the service anywhere else, for example on port 80, the client cannot find it because the client is looking on port 44300.

WCF Session problem

I'm new to WCF and have not much idea. By using a sample code I tried WCF through remoting...
It works fine for few min but if i leave the client without accessing the WCF server I get an exception like this....
Exception:Unable to connect to the remote server.
Inner Exception :
System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 122.165.27.38:80
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
Stack Trace :
at System.Net.HttpWebRequest.GetRequestStream()
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at TeleMailer.TeleMailer.cbxtmuname_SelectedIndexChanged(Object sender, EventArgs e)
Source :
System
Exception :Server was unable to process request. ---> The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.
Inner Exception :
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 TeleMailer.Server.Service.get_path()
at TeleMailer.TeleMailer.TeleMailer_Load(Object sender, EventArgs e)
Source :
System.Web.Services
But it's not in faulted state nor it's closed!!!
Actually in my application the client communicates to the server which in turn contacts the WCF and gives him the work to do....
Right now I'm using Cassini as my server. It works great for few min but after nearly ten min it just shows this error message.... but if i restart my Cassini it works properly for few min again and gets the problem....
I cant understand how it goes to faulted state when it's able to connect more clients....
is it because the session has timed out or what? and if session has timed out then from which side from my server or client???
Any Idea plz..........
I've been siting with it for whole day but could not trace out any thing!!!
It may be a timeout problem, related to when you create the wcf proxy object in your client code.
It looks like you create the proxy object when you start the client and then just reuse it. This object maintains a connection to the server, which timesout after 10 min.
A better way to do it would be to create a new proxy object with a using statement, each time you need it.
" if i leave the client without accessing the WCF server I get an exception like "
May be due to inactivityTimeout, so you can increase it, or dispose your client object as soon as possible (try using statement)
you can set the property as follows
<reliableSession ordered="true" inactivityTimeout="00:00:05"
enabled="false" />