how to know why WCF service stopped - c#

We have developed WCF service and hosted as windows service. We have written .net core client application.
We have observed that the service is not responding after a few calls. It gets stopped somehow.
I tried to create logging and trace in WCF service but it is not creating any .svclog file.
In exception handling, it gives the following message
Exception: One or more errors occurred. (An error occurred while
sending the request.) System.ServiceModel.CommunicationException: An
error occurred while sending the request. --->
System.Net.Http.HttpRequestException: An error occurred while sending
the 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 (10054): An
existing connection was forcibly closed by the remote host. --- End
of inner exception stack trace --- at
System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError
error, CancellationToken cancellationToken) at
System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.GetResult(Int16
token) at
System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage
request, CancellationToken cancellationToken)
I want to know what forced the service to be stopped? How can I find this?

Related

Getting "System.Net.WebException: The underlying connection was closed: The connection was closed unexpectedly." error while calling web api

In my application, there is a functionality to extract reports based on a date range. In the background, it is calling my Web API with authentication(A), which consists of api caller functionality using httpclient, which is calling another non-secured DMZ server API (B) and a DMZ API-caliing WCF service (C) to collect data from the database.
My problem is that whenever I select a large date range, I get the following error in my WebAPI (A).
System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The underlying connection was closed: The connection was closed unexpectedly.
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)
--- End of inner exception stack trace ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at LRAS.OrderServices.Core.Helpers.ApiCaller.d__4.MoveNext()
What I have tried: I have increased the httpclient timeout from 300 to 1000 seconds, but it is breaking nearly every minute.
You can try several methods:
1.Configure the service point security protocol and select the SecurityProtocolType that suits you (Tls12, Ssl3, Tls, Tls11).
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
C# System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send
2.Set the ConnectionClose property of HttpClient.
_client.DefaultRequestHeaders.ConnectionClose = true;
HttpClient throwing "An error occurred while sending the request."
3.Try to hold the request long enough for it to complete normally and receive a valid response.
_client.DefaultRequestHeaders.Add("Connection", "Keep-Alive");
_client.DefaultRequestHeaders.Add("Keep-Alive", "3600");
.NET HttpClient - An existing connection was forcibly closed by the remote host

Connect an .NET WebSockets client to a node.js socket.io server

I am currently supporting an older application which has a node.js (v0.12.13) server with a socket.io (v1.3.7) connection. This server supports a browser clients very well.
socket.attach(http, { 'transports': ['polling','websocket'], 'allowUpgrades': true });
socket.attach(https, { 'transports': ['polling','websocket'], 'allowUpgrades': true });
socket.sockets.on('connection', function (socket) {
// Process stuff here
});
Our requirements also required that we allow our legacy Windows app to connect to the node server and I had used SocketIoClientDotNet/EngineIoClientDotNet, and this more or less works OK (with some exceptions that I need to handle).
So I thought I would try to use a .NET ClientWebSocket approach, where uri="ws://10.10.5.112", based on this article:
static async Task Connect(string uri)
{
ClientWebSocket sock = new ClientWebSocket();
await sock.ConnectAsync(new Uri(uri), CancellationToken.None);
}
But I get the following exceptions:
System.AggregateException
HResult=0x80131500
Message=One or more errors occurred.
Source=mscorlib
StackTrace:
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
at WebsocketClientTest.Program.Main(String[] args) in C:\Source\test\WebsocketClientTest\Program.cs:line 16
Inner Exception 1:
WebSocketException: Unable to connect to the remote server
Inner Exception 2:
WebException: The underlying connection was closed: The connection was closed unexpectedly.
Sure enough, I don't see any connection attempt at the server, but Wireshark is telling me that the .Net app is trying to initiate the connection, but gets no response from the node.js server. Looks like this a failure at the socket.io side, but any ideas to help me along are appreciated.

Can't connect to Azure Blob Storage from App Service

I am trying to connect to a Azure Blob Storage account from an App Service hosted within the same location and in the same resource group. However when attempting to create a container during startup I get the following exception:
System.AggregateException: One or more errors occurred. (An error
occurred while sending the request.) --->
Microsoft.WindowsAzure.Storage.StorageException: An error occurred
while sending the request. ---> System.Net.Http.HttpRequestException:
An error occurred while sending the request. --->
System.Net.Http.WinHttpException: A connection with the server could
not be established
The inner exception is:
Microsoft.WindowsAzure.Storage.StorageException: An error occurred while sending the request. ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.Http.WinHttpException: A connection with the server could not be established
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Threading.Tasks.RendezvousAwaitable`1.GetResult()
at System.Net.Http.WinHttpHandler.d__105.MoveNext()
--- End of inner exception stack trace ---
I have double checked the account name, URL and access keys. I have also tried cycling the access keys to be sure. I have tried connecting to another storage account from the same app service and that also fails.
There are no app firewalls or VNets in place on either resource and I am at a loss as to what could be causing the issue.

Xamarin-PCL iOS SignalR via Https Error

I've got a problem when using SignalR on Xamarin-PCL project. The error occurred when connection.start() (The hub url is https) method, But it's worked perfectly on Android.
This is the error message
System.AggregateException: One or more errors occurred. ---> System.Net.Http.HttpRequestException: An error occurred while sending the request ---> System.Net.WebException: Error getting response stream (ReadDone1): ReceiveFailure ---> System.IO.IOException: Unable to read data from the transport connection: Connection reset by peer. --->
Change the SSL/TLS implementation to "Mono (TLS v1.0)"

System.Net.Sockets.SocketException Disaster

In our Winforms client app that is disconnected from the business layer and communicates via MVC web API, we get a nasty error. Are there any experts out there who can please explain!
What does all this mean?
---> (Inner Exception #0) System.Net.Http.Httprequestexception: An Error Occurred While Sending The Request.
---> System.Net.Webexception: The Underlying Connection Was Closed: An Unexpected Error Occurred On A Receive.
---> 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.Endreceive(Iasyncresult Asyncresult)
At System.Net.Sockets.Networkstream.Endread(Iasyncresult Asyncresult)
--- End Of Inner Exception Stack Trace ---
At System.Net.Sockets.Networkstream.Endread(Iasyncresult Asyncresult)
At System.Net.Pooledstream.Endread(Iasyncresult Asyncresult)
At System.Net.Connection.Readcallback(Iasyncresult Asyncresult)
--- End Of Inner Exception Stack Trace ---
At System.Net.Httpwebrequest.Endgetresponse(Iasyncresult Asyncresult)
At System.Net.Http.Httpclienthandler.Getresponsecallback(Iasyncresult Ar)
--- End Of Inner Exception Stack Trace ---<---
Well, in general, this exception is very vexing, indeed. But what you have expected? You are working with the network. It lies down and gets up frequently. There are two main reasons of such a behaviour:
The quality of the network in which the code is executing.
Errors made by programmers if they implemented their own protocol of communication.
If these two reasons are not in place, then you should implement something like auto connection using timeouts. Also, the TCP-protocol implemetation internals will be very helpful!

Categories

Resources