Need help understanding Microsoft Service Trace Viewer log - wcf

I'm using Microsoft Service Trace Viewer to check a log for an exception. Exception is:
An error occurred while receiving the HTTP response to ...someservice.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.
The webservice is up and running, and I can reach it fine. I'm generating several reports using methods from the same webservice, and all is fine except one. (this report has a lot of data). I'm guessing it has to do with returning too much data / timeout, but how can I examine this using Microsoft Service Trace Viewer? (I'm new at this tool).
This is my exception string:
<ExceptionString>System.ServiceModel.CommunicationException: An error occurred
while receiving the HTTP response to http://someservice.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.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.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.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
--- End of inner exception stack trace ---</ExceptionString>
Please help, I really got no clue here...

To try to get a more specific error, enable tracing on both the client and the service, see the links below for more information. Once you have a .svclog file, open it with the trace viewer and click on any activities highlighted in red to view details - if you're exceeding a WCF limit such as MaxReceivedMessageSize it should appear in the log for either the client or service.
http://msdn.microsoft.com/en-us/library/ms733025.aspx
How to turn on WCF tracing?

A common cause for this from what I've encountered is a DataContractSerializer exception. Usually it's a circular reference for me.
Typically what I will do is leave a commented block of code in the service somewhere that uses DataContractSerializer to manually serialize the object that is about to return. You will get a more useful message from the exception it generates.
Assuming you have a "value" variable, here is one way to accomplish the task:
var xs = new DataContractSerializer(value.GetType());
var ms = new MemoryStream();
xs.WriteObject(ms, value);
Then I will execute the code to examine the exception.

Related

Example of a .Net6 Blazor WebAssembly application with authentication using local Sql Db?

I'm trying to add authentication (with registration, password reset etc) to a .Net6 Blazor WebAssembly project. When creating the project include authentication for individual accounts (to local sql db), configure for HTTPS, Asp.Net Core hosted and Progressive Web Application. This is done in VS 2022.
The problem I'm facing is that each project I've created so far continues to crash as soon as I try to register or login.
similar to this thread: Blazor WebAssembly Hosted Proxy crash on successful authentication
I also looked at the link to https://github.com/dotnet/aspnetcore/issues/26635 but the issue was resolved. I'm currently running Chrome Version 99.0.4844.82 (Official Build) (64-bit).
I tried removing the autocomplete attribute on the server side cshtml pages but the project still random crashes.
Has anyone successfully implemented authentication (using local Sql) in a webAssebly project with .Net6?
I also tried to run the samples from the .NetCore git repo and the apps continue to crash.
This is the server console output:
fail: Microsoft.WebAssembly.Diagnostics.DevToolsProxy[0] DevToolsProxy::Run: Exception System.AggregateException: One or more errors occurred. (The remote party closed the WebSocket connection without completing the close handshake.) ---> System.Net.WebSockets.WebSocketException (0x80004005): The remote party closed the WebSocket connection without completing the close handshake. ---> System.Net.Sockets.SocketException (995): The I/O operation has been aborted because of either a thread exit or an application request. at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketAwaitableEventArgs.g__ThrowSocketException|5_0(SocketError e) at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketAwaitableEventArgs.GetResult(Int16 token) at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketConnection.DoReceive() at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result) at System.IO.Pipelines.Pipe.GetReadAsyncResult() at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1UpgradeMessageBody.ReadAsyncInternalAwaited(ValueTask1 readTask, CancellationToken cancellationToken) at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder1.StateMachineBox1.System.Threading.Tasks.Sources.IValueTaskSource<TResult>.GetResult(Int16 token) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpRequestStream.ReadAsyncInternal(Memory1 destination, CancellationToken cancellationToken) at System.Net.WebSockets.ManagedWebSocket.EnsureBufferContainsAsync(Int32 minimumRequiredBytes, CancellationToken cancellationToken, Boolean throwOnPrematureClosure) at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder1.StateMachineBox1.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token) at System.Net.WebSockets.ManagedWebSocket.ReceiveAsyncPrivate[TResult](Memory1 payloadBuffer, CancellationToken cancellationToken) at System.Net.WebSockets.ManagedWebSocket.ReceiveAsyncPrivate[TResult](Memory1 payloadBuffer, CancellationToken cancellationToken) at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder1.StateMachineBox1.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token) at System.Threading.Tasks.ValueTask`1.ValueTaskSourceAsTask.<>c.<.cctor>b__4_0(Object state) --- End of stack trace from previous location --- at Microsoft.WebAssembly.Diagnostics.DevToolsProxy.ReadOne(WebSocket socket, CancellationToken token) --- End of inner exception stack trace --- at Microsoft.WebAssembly.Diagnostics.DevToolsProxy.Run(Uri browserUri, WebSocket ideSocket)
This is the VS output screen details:
Exception thrown: 'System.Net.Sockets.SocketException' in Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.dll
Exception thrown: 'System.Net.Sockets.SocketException' in Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.dll
The program '' has exited with code 4294967295 (0xffffffff).
Exception thrown: 'Microsoft.AspNetCore.Connections.ConnectionResetException' in System.Private.CoreLib.dll
Exception thrown: '' in Unknown Module.
The thread 0x1 has exited with code 0 (0x0).
The program 'service-worker.js' has exited with code 4294967295 (0xffffffff).
The program '[25288] Chatter.Server.exe' has exited with code 4294967295 (0xffffffff).
The thread 0x0 has exited with code 0 (0x0).
The program 'localhost:7151' has exited with code 4294967295 (0xffffffff).
Any advise will be greatly appreciated.
Thanx
Riaan
fail: Microsoft.WebAssembly.Diagnostics.DevToolsProxy[0]
DevToolsProxy::Run: Exception System.AggregateException: One or more
errors occurred. (The remote party closed the WebSocket connection
without completing the close handshake.)
To the above error, as far as I know, after update to VS 2022 17.1, it will show the websocket error. And, if check the console output, you will find the above error.
To solve the above error, you can try to use the VS 2022 17.2.0 Preview 2.0 version, this issue has been fixed in this version. Or you can try to install the earlier VS 2022 version, refer this link. I also check it using VS 2022 17.0.4 version, it doesn't have this error, you can try to use this version.
To the Local SQL Server error, I guess you are meeting the following error, right?
To solve the above error, you can use the following migration commands to generate the DataBase first (Or you can use the existing database), then the above error will disappear when you run the application.
add-migration generateDatabase
Update-Database
More detail information about migration, see Migrations Overview.

System.IO.IOException: 'The cloud file provider is not running

.svc (wcf) project don't start on Local IIS
the project was running normally.
but when he bought a new computer, it stopped working.
It may be because iis settings have changed. How can I fix
Error Image
System.IO.IOException
HResult=0x8007016A
Message=The cloud file provider is not running.
Source=mscorlib
StackTrace:
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.ReadCore(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.FileStream.Read(Byte[] array, Int32 offset, Int32 count)
at System.IO.StreamReader.ReadBuffer()
at System.IO.StreamReader.get_EndOfStream()
at Microsoft.Tools.TestClient.ApplicationSettings.ReadSettingFile()
at Microsoft.Tools.TestClient.ApplicationSettings..ctor()
at Microsoft.Tools.TestClient.ApplicationSettings.GetInstance()
at Microsoft.Tools.TestClient.UI.MainForm.ConstructRecentServiceMenuItems()
at Microsoft.Tools.TestClient.UI.MainForm..ctor()
at Microsoft.Tools.TestClient.UI.MainForm..ctor(String[] endpoints)
at Microsoft.Tools.TestClient.Program.Main(String[] args)
This exception was originally thrown at this call stack:
[External Code]
I think there was a connectivity problem with OneDrive. The problem was solved after restarting the computer

Why would DeviceClient SetDesiredPropertyUpdateCallbackAsync timeout immediately after OpenAsync succeeded?

As part of my initialization of an IoTHub DeviceClient I explicitly open the connection with OpenAsync and then immediately call SetDesiredPropertyUpdateCallbackAsync. Sometimes when I call SetDesiredPropertyUpdateCallbackAsync it times out with an exception. If my network connection is stable, why don't I get the timeout on OpenAsync instead of SetDesiredPropertyUpdateCallbackAsync? I believe it even makes the same OpenAsync call internally to ensure the connection is open.
ioTHubModuleClient = DeviceClient.CreateFromConnectionString(ConnectionString, settings);
await ioTHubModuleClient.OpenAsync().ConfigureAwait(false);
await ioTHubModuleClient.SetDesiredPropertyUpdateCallbackAsync(OnModulePropertyUpdateRequested, this).ConfigureAwait(false);
Update:
I found that if I register with SetConnectionStatusChangesHandler before that, I can see that its endlessly connecting/disconnecting until it times out when I call SetDesiredPropertyUpdateCallbackAsync.
IoTHub connection is now Connected Reason: Connection_Ok
IoTHub connection is now Disconnected_Retrying Reason: No_Network
IoTHub connection is now Connected Reason: Connection_Ok
IoTHub connection is now Disconnected_Retrying Reason: No_Network
IoTHub connection is now Connected Reason: Connection_Ok
IoTHub connection is now Disconnected_Retrying Reason: No_Network
I used dotPeek to decompile the Microsoft.Azure.Devices stuff and serve it up through a local pdb server. What seems to be happening is that something is generating a SocketException for a successful operation. The exception messages is "The operation completed successfully". This blog indicates this is typically due to a dllimport call not using SetLastError. I don't see anything in the callstack that obviously leads to a pinvoke call though:
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.Devices.Client.Transport.Mqtt.MqttIotHubAdapter.d__40.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.Devices.Client.Transport.Mqtt.MqttIotHubAdapter.d__28.MoveNext()
Generally, when working in a Console App or Service scenario, there is no SynchronizationContext installed (by default), so the continueOnCapturedContext option in ConfigureAwait will have no effect.However if you happen to install or use a library that installs a SynchronizationContext, the behavior of the async methods will be like in UI application. ConfigureAwait(false) will change the context.An important rule is that each async method has its own context,it means that the calling method is not affected by ConfigureAwait. You can refer to these topics to get good know details about Task.ConfigureAwait.
ConfigureAwait(false) not needed in Console/Win service apps, right?
Why would I bother to use Task.ConfigureAwait(continueOnCapturedContext: false);

Uploading a file to REST WCF service connection forcibly closed issue

I have WCF websrvice Hosted on IIS 7.5 and IIS8, and I'm suing a REST endpoint to communicate to web service from my web application.
I'm using httpWebrequest to upload a file and I have set each and every setting possible in web.config of both sides to make sure asp.net will let me upload large files.
Its working fine with large files in IIS 8 but in IIS 7.5 I get the following Error:
Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 10/02/2014 4:04:39 PM
Event time (UTC): 10/02/2014 6:04:39 AM
Event ID: 8aea1d07d67743ba81a4c46bcd622ed1
Event sequence: 63
Event occurrence: 1
Event detail code: 0
Application information:
Application domain: /LM/W3SVC/1/ROOT/OP.Web-1-130364857480032265
Trust level: Full
Process information:
Process ID: 5320
Process name: w3wp.exe
Account name: IIS APPPOOL\MyApplication AppPool
Exception information:
Exception type: IOException
Exception message: 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)
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)
I would be thankful if you help me with this issue.
There are two different places where request size can be specified in IIS, as explained
in this answer. Maybe additional places within the WFC architecture also. But all of them are limited to 4GB (or 2GB in some cases). In one of our implementations, we found the best route to be that we host a custom Owin based web server to specifically handle uploaded requests. It takes a few lines of code to get that up and running, and there are samples available on asp.net website.

Silverlight3.0 + WCF Service hosting issues: Communication Exception

I am working with silverlight3 with WCF service for a while.. I have developed and hosted my application into client mechine. It was working good. Then i need to do some modifications in my application, so I have added new functions in to my .svc file(i.e in to the wcf service). I have updated the servicereference successfully. When i re published and access it, it throws the error in a particulare method which i newly added.. But the other functions and data retreival are working good.. The newly added functions of the wcf services throws the communication error.
This is the function which i used to bind the combobox by the data retrieved from the wcf service..
Actual Error:
System.Reflection.TargetInvocationException: An exception occurred during the operation, making the result invalid. Check InnerException for exception details. ---> 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.b_4(Object sendState)
at System.Net.Browser.AsyncHelper.<>c_DisplayClass2.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.ClientBase1.ChannelBase1.EndInvoke(String methodName, Object[] args, IAsyncResult result)
at foundproject.ServiceReference1.Service1Client.Service1ClientChannel.EndUsergetBasedWorkgroup(IAsyncResult result)
at foundproject.ServiceReference1.Service1Client.ServiceReference1_IService1_EndUsergetBasedWorkgroup(IAsyncResult result)
at foundproject.ServiceReference1.Service1Client.OnEndUsergetBasedWorkgroup(IAsyncResult result)
at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)
--- End of inner exception stack trace ---
at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()
at foundproject.ServiceReference1.UsergetBasedWorkgroupCompletedEventArgs.get_Result()
at foundproject.UserMaster.BindUsers(Object sender, UsergetBasedWorkgroupCompletedEventArgs e)
Please Please help me to solve it out..
It will be a great help for me..
Thanks
Lakshmi.A
All methods in webservice are implemented using Interfaces, if you have added your function in Class file make sure its implemented by its interface-template/interface-method signature.
You have not changed the namespace of the newly added method.
the access modifier is public.
Try running your webservice file "svc" from IIS Management Console using Browse by Right clicking on "svc" file. it must show a default web service UI that we normally expect.
Debug your web service, and see if it hits the break point over your newly added method.
I'm sure by following these simple steps you will solve your problem.