Blazor server showing 'Invocation canceled due to the underlying connection being closed' - signalr

We have a Blazor server side webapp with signalr hosted on IIS. We added EventListener for Blazor.start() with reconnectionHandler and reconnectionOptions. When opening the site as part of previous tabs or turning on after a long sleep, the website shows the "An error has occurred. This application may no longer respond until reloaded." error and the console error shows
Error: The list of component records is not valid.
Uncaught (in promise) Error: Invocation canceled due to the underlying connection being closed.
at e.connectionClosed (blazor.server.js:1:27242)
at e.connection.onclose (blazor.server.js:1:17377)
at e.stopConnection (blazor.server.js:1:61423)
at e.transport.onclose (blazor.server.js:1:59077)
at e.close (blazor.server.js:1:47811)
at e.stop (blazor.server.js:1:47400)
at e.<anonymous> (blazor.server.js:1:52950)
at blazor.server.js:1:49394
at Object.next (blazor.server.js:1:49499)
at a (blazor.server.js:1:48266)
There is no load balancing and websockets are enabled in IIS. I checked around on Blazor github and some of the solutions suggested solutions was to add a no-cache meta tag in _Host.cshtml like
<meta http-equiv="Cache-Control" content="no-store" />
Even after adding this, we still get the above errors. Are we missing anything on our end? Any help would be appreciated.
The error does not occur when normally using the application. The signalr works fine.

I had this exact same issue before and found this on github detailing the same issue
As mentioned by Steve, put the following inside the body tag on _Host.chtml instead of putting it as a meta tag.
#{
Response.Headers["Cache-Control"] = "no-store";
}

Related

SignalR negotiate fails (Bad Gateway)

Someone any idea, I’ve been struggling with this for some time.
I'm using SignalR (Asp.net 5). when I try to debug local (ISS 10.0 express) everything is working fine. SignalR is working (Long poll).
Now when I publish the app to Azure it I can access : .azurewebsites.net/signalr/hubs
but I cannot access .azurewebsites.net/signalr/hubs/negotiate
it returns:
The specified CGI application encountered an error and the server terminated the process.
When my web app calls $.connection.hub.start() it will fail.
GET XHR http://xxxx.azurewebsites.net/signalr/negotiate [HTTP/1.1 502 Bad Gateway]
I’m running out of idea's. Don't know how I can get more debug information.
Small selection of my ‘already tried’ list:
Set $.connection.hub.url path manual to http://xxxx.azurewebsites.net/signalr/
Enable/Disable websockets
Removed forwardWindowsAuthToken from the web.config httpPlatform
EDIT:
Now getting more details on this error:
CryptographicException: The data protection operation was unsuccessful. This may have been caused by not having the user profile loaded for the current thread's user context, which may be the case when the thread is impersonating.
Still absolutely no idea how to solve this!
Solved by using appBuilder.UseAesDataProtectorProvider();
(from Owin.Security.AesDataProtectorProvider;)
I have no idea if this is the best solution.

Web Api 2 Self Host with identity individual account

I have been trying to create a web api 2 that is secure with individual account.
So I can easily create WebApi2 with individual account, see link below
http://www.asp.net/vnext/overview/authentication/individual-accounts-in-aspnet-web-api
And Self hosting is easy to do.
http://www.asp.net/web-api/overview/hosting-aspnet-web-api/use-owin-to-self-host-web-api
But I cannot figure out how to combine the solutions.
Far as I got was adding a console app to a webapi2. Which seems to run. But whenever I try and get the access token it returns
An unhandled exception of type 'System.Net.WebException' occurred in System.dll
Additional information: The remote server returned an error: (500) Internal Server Error.
If anyone knows of a solution that would be great. Thanks
This post is way old, but to anyone else who is having this issue and finds this question, I was able to get past the 500 Error by adding app.UseWebApi(config); after setting up config, as mentioned in this post:
http://odetocode.com/blogs/scott/archive/2013/07/24/self-hosting-webapi-with-katana.aspx
HOWEVER, I'm now getting a 401, unauthorized request for all of my requests, even though I have a valid token and I'm sending it the same way I did that worked in the non-self-hosted WebApi2 app. but I'm one step closer anyways.

reCaptcha validation with timeout exception

I am using reCaptch in my MVC 3 web app running in the localhost.
Things were working fine few weeks back but suddenly failing.
Suddenly getting this error.
if(!ReCaptcha.Validate(_config.RecaptchaPrivateKey)){ <-- times out here
//process other fields in the form
}
As soon as I fill the form and hot submit I get this error :
The operation has timed out
Description : An unhandled exception occurred during the execution of the current ...
Exception Details : System.Net.WebException: The operation has timed out
Is this a proxy issue?
Is this because my site on localhost runs on port 3316?
localhost:3316/user/signup
I saw some posts that suggests that reCAPTCHA expects port 80 but my app runs on port 3316
What can be the issue?
Thanks
I got around this by creating proxy class that inherits IWebProxy.
Then specifying to use this proxy when internal, I had to transform it out for other environments that didn't need to use it.
See this question and accepted answer:
Is it possible to specify proxy credentials in your web.config?
The above link took some finding, so I favourited it for future use.

irregular security error loading data with HTTP request flex 3.2 application

I have an application that worked for a client for 2 years now. All of a sudden it stopped working
and I traced it to a 'security error' that I get when attempting to get data from a php script that reads data from a mysql DB. It seems that data (a tab in a textfield) triggers that event, but it is irregular over various clients. Sometimes it works, sometimes it doesn't. The script is OK, getting the data from a regular HTTP request in the browser works fine. Is there anyone who recognizes this behaviour ? I'm at a loss. The error is this:
Could not load any date from server ![FaultEvent fault=[RPC Fault faultString="Security error accessing url" faultCode="Channel.Security.Error" faultDetail="Destination: DefaultHTTP"] messageId="6D8CAADA-D95F-F30D-0C2A-5AC1F3061A23" type="fault" bubbles=false cancelable=true eventPhase=2]
and the script I read is here:
http://www.arti.nl/flyer/services/exhibitions.php
the application that uses it is the 'flyer' application you can trigger by clicking the red triangle in the agenda on this site:
www.arti.nl.
Thanks a lot !
Jonathan

Blazor Server - the circuit failed to initialize

I have published the BlazorApp1 app created by the VS2019 Blazor template to a production server. Since it is a sub-site, I made 3 changes:
in _Host.cshtml replaced the base tag with <base href="/BlazorApp1/" >
in Startup.cs added app.UsePathBase("/BlazorApp1")
in web.config, changed the hostingModel to outofprocess and stdoutLogEnabled to true
When navigating to the site I almost always get the following error:
Unhandled Exception Page must be reloaded
This is displayed in the browser console: (replaced my site with contoso)
[2020-06-02T18:39:49.445Z] Information: Normalizing '_blazor' to 'http://www.contoso.com/BlazorApp1/_blazor'. blazor.server.js:1:5212
[2020-06-02T18:39:49.936Z] Information: WebSocket connected to ws://www.contoso.com/BlazorApp1/_blazor?id=5yq6pI_jo1ByPZtskEjjmw. blazor.server.js:1:5212
[2020-06-02T18:39:50.132Z] Error: The circuit failed to initialize. blazor.server.js:15:27309
log http://www.contoso.com/BlazorApp1/_framework/blazor.server.js:15
C http://www.contoso.com/BlazorApp1/_framework/blazor.server.js:8
S http://www.contoso.com/BlazorApp1/_framework/blazor.server.js:8
invokeClientMethod http://www.contoso.com/BlazorApp1/_framework/blazor.server.js:1
invokeClientMethod .../BlazorApp1/_framework/blazor.server.js:1
processIncomingData .../BlazorApp1/_framework/blazor.server.js:1
onreceive .../BlazorApp1/_framework/blazor.server.js:1
onmessage .../BlazorApp1/_framework/blazor.server.js:1
[2020-06-02T18:39:50.141Z] Information: Connection disconnected. blazor.server.js:1:5212
Error: Invocation canceled due to the underlying connection being closed. blazor.server.js:1:20001
I can't find any other clues about what's happening. There are no exceptions shown in the log.
The problem was resolved by using only lowercase characters in the <base> tag:
<base href="/blazorapp1/" >
It has just happened to me as well, but I had the base tag specified correctly. This error can also occur in a rare case when you have ambiguous constructors defined for one of your dependency injected services if both match all the parameters (possibly by accident due to inheritance). The verbose log won't point to that issue. Be aware that purposeful creation of multiple constructors for dependency injected services is considered an anti-pattern.
For me it happened because I put an async call inside a constructor of a class in DI, so, yeah, that's a stupid error which can mean anything.

Resources