Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

Intermittent Exception(s) occur launching ReactGrid, ReactReduxSpa #116

Closed
antmdvs opened this issue Jun 7, 2016 · 15 comments
Closed

Intermittent Exception(s) occur launching ReactGrid, ReactReduxSpa #116

antmdvs opened this issue Jun 7, 2016 · 15 comments

Comments

@antmdvs
Copy link

antmdvs commented Jun 7, 2016

On Windows 7 SP1, I'm experiencing intermittent exception(s) launching ReactGrid, ReactReduxSpa. Exception details can be found below. I have not been able to repro on my Win10 machine using Chrome, IE, or Edge.

First, I suspected it was a MAXPATH issue because my content dir was several levels deep, but I cloned the repo into a short path C:\Git\JavaScriptServices\ and am still experiencing this behavior. I've also noticed that ReactGrid and ReactReduxSpa (AFAIK) are the 2 React projects that employ SSR. I haven't been able to repro this on Windows 7 SP1 with the simple (CSR-only) ReactSpa using Chrome 50 or IE 11.

Internal Server Error.html.txt

Raw Details:

System.Net.Http.WinHttpException: A connection with the server could not be established
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at System.Net.Http.WinHttpHandler.<StartRequest>d__102.MoveNext()
@antmdvs
Copy link
Author

antmdvs commented Jun 7, 2016

Update 1:

When I wrote the issue above, both ReactGrid and ReactReduxSpa were giving the same exceptions (IIS Express was listening on 49552). I just now changed the Startup Project in VS 2015 to ReactGrid, attempted to run it (unsuccessfully) without stopping ReactReduxSpa (49552), then switched the Startup Project back to ReactReduxSpa and it's launching without error... for now.

iis express

I'm not sure if this has anything to do with anything but I'm just throwing it out there.

@antmdvs
Copy link
Author

antmdvs commented Jun 7, 2016

Update 2:

I just used the yeoman generator instead of running the template(s) directly and I'm no longer getting the dev exception page with the stack trace. However, I am still seeing the exception crop up in bursts of 4 or 5 every time I refresh the browser in the Debug output in VS:

Exception thrown: 'System.Net.Http.WinHttpException' in System.Net.Http.dll
Exception thrown: 'System.Net.Http.WinHttpException' in System.Net.Http.dll
Exception thrown: 'System.Net.Http.WinHttpException' in System.Net.Http.dll
Exception thrown: 'System.Net.Http.WinHttpException' in System.Net.Http.dll

@antmdvs
Copy link
Author

antmdvs commented Jun 7, 2016

Update 3

After a cold boot of Windows 7 SP1, the page of death included in my original post came back in Chrome 51. I tried waiting and refreshing the browser several times to no avail. A few minutes later I launched IE 11 and the site rendered properly there. Immediately after that, the site was also rendering fine in Chrome. No other user interactions were taken.

@antmdvs
Copy link
Author

antmdvs commented Jun 8, 2016

I changed my exception settings to break on all .NET Exceptions, which reveals:

System.Net.Http.WinHttpException occurred
Message: Exception thrown: 'System.Net.Http.WinHttpException' in System.Net.Http.dll
Additional information: The option is invalid

at this location:

callstack

..I see someone else is having a similar issue:
http://stackoverflow.com/questions/37469122/asp-net-5-tag-returning-500-internal-server-error/37499200#37499200?newreg=d4bc81f2c9f74f9db13b51a7f7819236

As the SO poster suggests, if I comment out the prerender tag helpers in Index.cshtml, the problem goes away. Any thoughts?

Thanks!

@SteveSandersonMS
Copy link
Member

I'm not certain what specific problem occurs with WinHttpHandler on Windows 7. Using such an old OS is quite an unusual case, and a low-level bug in an OS service might be beyond what this repo can do anything about.

Rather than get too deep into that, can you try the following possible workaround? Instead of using the HTTP-based .NET/Node interop, you can switch over to a new hosting model which is soon going to become the new default, because it's faster than the HTTP interop mechanism.

  1. Make sure you have the latest version of the Microsoft.AspNetCore.NodeServices package - version 1.0.0-beta-000003

  2. Add the following to the ConfigureServices method in your Startup.cs file:

    services.AddNodeServices(new NodeServicesOptions { HostingModel = NodeHostingModel.Socket });
    

    (you'll probably also need to add using Microsoft.AspNetCore.NodeServices; at the top of the file)

This at least avoids the HTTP aspect of things. Does this work?

@antmdvs
Copy link
Author

antmdvs commented Jun 13, 2016

Hi Steve, unfortunately that didn't seem to work. I'm still getting the WinHttpException for one. I'll provide more details shortly.

@antmdvs
Copy link
Author

antmdvs commented Jun 13, 2016

  1. I verified v.1.0.0-beta-000003
  2. I added the code you provided above to Startup.cs.

The symptoms remain intermittent. At times, I get 502.3 Bad Gateway (details below) when launching the app for the first time. (This never happened before I modified the code per your instructions.)

Sometimes, a browser refresh will allow the page to display properly, but I still see 4 "WinHttpException"s in the VS output window.


HTTP Error 502.3 - Bad Gateway
The specified CGI application encountered an error and the server terminated the process.

Most likely causes:
The CGI application did not return a valid set of HTTP errors.
A server acting as a proxy or gateway was unable to process the request due to an error in a parent gateway.

Things you can try:
Use DebugDiag to troubleshoot the CGI application.
Determine if a proxy or gateway is responsible for this error.

Detailed Error Information:
Module AspNetCoreModule
Notification ExecuteRequestHandler
Handler aspNetCore
Error Code 0x80072ee2
Requested URL http://localhost:60389/
Physical Path C:\Git\rryo
Logon Method Anonymous
Logon User Anonymous
Request Tracing Directory C:\Users________\Documents\IISExpress\TraceLogFiles\RRYO

More Information:
This error occurs when a CGI application does not return a valid set of HTTP headers, or when a proxy or gateway was unable to send the request to a parent gateway. You may need to get a network trace or contact the proxy server administrator, if it is not a CGI problem.
View more information »

@SteveSandersonMS
Copy link
Member

Thanks for the updated information. Sorry this is being troublesome for you. Is it still definitely only happening on your Windows 7 machine and not on Windows 10?

It's not likely that I'm going to have capacity to investigate this if it's Windows 7-specific. The error looks pretty low-level and most likely is independent of anything that NodeServices controls directly. If you are able to diagnose this fault I'd be very interested to know the details. Otherwise, at least in the short term, we might have to amend the requirements list for NodeServices to specify Windows 8 or above. I know that won't be ideal from your perspective, and if this gets reported by more people then the plan might change. Does that make sense?

@antmdvs
Copy link
Author

antmdvs commented Jun 13, 2016

Is it still definitely only happening on your Windows 7 machine and not on Windows 10?

I'll try on Windows 10 today and post back.

Does that make sense?

Yup. In the meantime, I'll try to dust off my WinDbg+SOS when I have some time and see if I can get to the root of it. I'd love to be able to get SSR; it's a great selling point and a shame to have to disable it.

@antmdvs
Copy link
Author

antmdvs commented Jun 14, 2016

The following exception occurs on both Windows 7 SP1 and Windows 10:

Object reference not set to an instance of an object.

   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at Microsoft.AspNetCore.NodeServices.HostingModels.VirtualConnections.VirtualConnectionClient.OpenVirtualConnection()
   at Microsoft.AspNetCore.NodeServices.SocketNodeInstance.<Invoke>d__7`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Microsoft.AspNetCore.SpaServices.Prerendering.PrerenderTagHelper.<ProcessAsync>d__23.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner.<RunAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at Asp._Views_Home_Index_cshtml.<ExecuteAsync>d__23.MoveNext()

This exception is also intermittent and it's sometimes displayed by the DeveloperExceptionPageMiddleware. Other times, it results in "HTTP Error 502.3 - Bad Gateway" as mentioned earlier, and sometimes it works fine. It seems I can always repro it after restarting VS, however.

@SteveSandersonMS
Copy link
Member

If you can provide any information on how to repro that (even if the repro is intermittent like you mention) that would be great. It's difficult to begin any investigation without that info.

Based on the stack trace you posted, I identified one line of code in VirtualConnectionClient's OpenVirtualConnection method that's not thread-safe like it should be. This might be the cause of the error, but I can't be sure.

I've fixed this (3fc19ea) and pushed an updated build of all the packages. The new package version for all of them, which includes this fix, is 1.0.0-beta-000004 (e.g., https://www.nuget.org/packages/Microsoft.AspNetCore.NodeServices/1.0.0-beta-000004). Can you please update to beta-000004 and check if the problem still occurs?

If it does, I'll need more detailed steps that reproducing the issue (even if intermittently). Thanks!

@antmdvs
Copy link
Author

antmdvs commented Jun 20, 2016

Thanks, Steve. It's been a while since I pulled down the latest. I will try this today and post back.

@antmdvs
Copy link
Author

antmdvs commented Jun 20, 2016

Ok. I installed the latest yeoman generator and generated a fresh React-Redux app. No signs of WinHttpException so far (fingers crossed)!

The following may no longer be relevant, but if I add:
services.AddNodeServices(new NodeServicesOptions { HostingModel = NodeHostingModel.Socket });

then I still either get "HTTP Error 502.3 - Bad Gateway" or:

An unhandled exception occurred while processing the request.

IOException: Pipe is broken.
System.IO.Pipes.PipeStream.WriteAsyncCore(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)

AggregateException: One or more errors occurred. (Pipe is broken.)
System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)

AggregateException: The connection failed - see InnerException for details. (One or more errors occurred. (Pipe is broken.))
Microsoft.AspNetCore.NodeServices.HostingModels.VirtualConnections.VirtualConnectionClient.ThrowIfReadLoopFailed()

AggregateException: One or more errors occurred. (The connection failed - see InnerException for details. (One or more errors occurred. (Pipe is broken.)))
System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)

Speaking of, is Socket the new DefaultNodeHostingModel? It looks like it may still be Http, which contradicts the docs:

Code:

public const NodeHostingModel DefaultNodeHostingModel = NodeHostingModel.Http;

Docs:
https://github.com/aspnet/JavaScriptServices/blob/44c8b9985b63eb1a33dd3048c0b3b67732b12d08/src/Microsoft.AspNetCore.NodeServices/README.md#built-in-hosting-models

@antmdvs
Copy link
Author

antmdvs commented Jun 21, 2016

(cont.) My latest error looks like a duplicate of #110. I'm using beta 00004.

@SteveSandersonMS
Copy link
Member

Speaking of, is Socket the new DefaultNodeHostingModel? It looks like it may still be Http, which contradicts the docs:

You're right that these are currently inconsistent, but that won't be fore long. Socket will be the new default hosting model, but isn't in the current packages. I wrote in the docs that it is because it will be very soon.

My latest error looks like a duplicate of #110. I'm using beta 00004.

OK then, closing this as a duplicate of #110.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants