SignalR 2 fails on Azure - asp.net

I deployed an ASP.NET 5 MVC 6 app on Azure, and ran into this problem with SignalR 2:
when starting connection from client, call to
/signalr/negotiate?clientProtocol=1.5&connectionData=%5B%7B"name"%3A"gameHub"%7D%5D&_=1460028930688
fails with error 500.
The exception behind error 500 is this:
Exception Details:
System.Security.Cryptography.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.
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Stack Trace:
[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.]
I read and tried solution suggested at SignalR CryptographicException on AzureWebsites, but id didn't work for me.
As I understand, Azure doesn't allow LoadUserProfile.
Any workaround?

I had the same problem and my fix was to add a call to UseAesDataProtectorProvider() before my call to MapSignalR(). Hope this helps someone.

Related

My clone of draw.io fails doGet when authenticating to Google Drive

We have a clone of draw.io. We have made some modifications to the UI for increased functionality. This works on localhost. We then did the Google Drive authentication process. But it was done on version 12.1.7 of draw.io. That integrated with google drive, except when re-opening a previously saved file.[Error with this version discussed here:https://stackoverflow.com/questions/62889536/no-access-control-allow-origin-header-is-present-on-the-requested-resource]
So, we ported our changes to the recent version of draw.io ,version 13.4.5 (https://github.com/jgraph/drawio/releases/tag/v13.4.5). Now, we get a different error. When trying to authenticate <screen shot of pop-up just before error> we get:
Login attempts failed.Please try again later <screenshot of error message>. When we look at developer tools, we see this
HTTP Status 500 - Can't make API call memcache.Set in a thread that is neither the original request thread nor a thread created by ThreadManager
type Exception report
message Can't make API call memcache.Set in a thread that is neither the original request thread nor a thread created by ThreadManager
description The server encountered an internal error that prevented it from fulfilling this request.
exception
com.google.apphosting.api.ApiProxy$CallNotFoundException: Can't make API call memcache.Set in a thread that is neither the original request thread nor a thread created by ThreadManager
com.google.apphosting.api.ApiProxy$CallNotFoundException.foreignThread(ApiProxy.java:800)
com.google.apphosting.api.ApiProxy$1.get(ApiProxy.java:175)
com.google.apphosting.api.ApiProxy$1.get(ApiProxy.java:172)
com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:89)
com.google.appengine.api.memcache.MemcacheServiceImpl.quietGet(MemcacheServiceImpl.java:26)
com.google.appengine.api.memcache.MemcacheServiceImpl.put(MemcacheServiceImpl.java:69)
com.google.appengine.api.memcache.stdimpl.GCache.put(GCache.java:157)
com.mxgraph.online.AbsAuthServlet.doGet(Unknown Source)
javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
note The full stack trace of the root cause is available in the Apache Tomcat/8.0.32 (Ubuntu) logs.
Notice the line in <com.mxgraph.online.AbsAuthServlet>. It says “doGet” is throwing error. I am new to servlets and don’t know how to proceed. I did not find “doGet” in the file AbsAuthServlet.java .
Any help to solve this issue will be great.

Asp.net unhandled exception in timer callback crashes w3wp and error not logged

I am experiencing some randomly happening unhandled exception causing w3wp to crash. I want to trace the cause of that exception. I already have a global Application_Error handler override in my MvcApplication class, so the crash must be caused by some out-of-http-context exception. In order to replicate the problem I genereate one myself in a timer callback, and try to trace it. Simplified code like
public static class MonitorTimers
{
public static Timer _taskMonitorTimer = new Timer(state: null, dueTime: 1000, period: 1000, callback: (state) =>
{
throw new Exception("Ouch! Me dead.");
});
}
In my local development environment (iisexpress launched by VS2017) and test environment (IIS 8.5), when the app starts and then crashes, the following can be seen in event viewer:
The most useful Event 1325 and 1026 sourced from ASP.NET and .NET Runtime shows the stack trace - just the thing I need.
My problem is, in my production machine (also IIS 8.5) I can't find the useful event 1325. Only a crash report, bearing no more information than I know. So I don't know what caused the error. I could surround my timer callback with try...catch block but the error could well be caused by something else (unmanaged libraries, error in static class initialization) then I still can't trace.
So suggestions on why event 1325 is missing or some tools that can show the log and analyse the stack trace is greatly appreciated. Thank you.
So, in your case you generate Exception diring Loading of application domain.
When CLR load application domain it firstly init static fields. So, if your code has problem with static fields, then exception will throw until it specifies Application_Error handler.
One more point, Is your application take a lot of memory? There are 2 cases when application can not write logs and execute code in catch block: StackOverflowException and OutOfMemoryException. Can you check is it has some memory leaks or infinite recursion?
One more point: set in visual studion setting to break when any exception throwed.
One more point: It is better to move your initialization logic from static constructors to ApplicationStart or something like this. You can do it temporary, for catch the bag and then move it to previous state.

The EventLogWebEventProvider provider failed to log an event with the error code 0x80070057

I am writing WebEvent in my asp.net Application and it is working fine in both my development and production region.However, When I analyze Event Logs in production server for past couple of months.I see below event
The following exception was thrown by the web event provider 'EventLogProvider' in the application '/(MyApplicationName)' (in an application lifetime a maximum of one exception will be logged per provider instance):
System.Web.HttpException (0x80004005): The EventLogWebEventProvider provider failed to log an event with the error code 0x80070057.
at System.Web.Management.EventLogWebEventProvider.ProcessEvent(WebBaseEvent eventRaised)
at System.Web.Management.WebBaseEvent.RaiseInternal(WebBaseEvent eventRaised, ArrayList firingRuleInfos, Int32 index0, Int32 index1)
Although Occurrence is very low, still I am curious to understand why this is happening.I tried to do some research and found below link
http://forums.iis.net/t/1201176.aspx?IIS+Keep+hanging
According to this link, I may be passing some invalid argument while writing event log.
But I double checked my EventLog.WriteEntry method and I am using it in my application only in couple of places and moreover, I am passing static string message. If argument is invalid then it should occur every time I try to write event.
Can anyone please help me understanding possible cause for this event.is there any known issue when working with EvenLog?
Check your code you may be trying to perform an invalid operation.
In my case i was writing a file to C Drive after changing Location to D Drive Problem Resolved

ASP.NET related error

If you could help me with my problem, I'd really appreciate it. I'm unable to open my website in another computer, The following error occurs:
Server Error in '/WebSite2' Application.
An attempt to attach an auto-named database for file C:\Users\evisen\Desktop\Amy the conqueror\WebSite2\App_Data\Database.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: An attempt to attach an auto-named database for file C:\Users\evisen\Desktop\Amy the conqueror\WebSite2\App_Data\Database.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
I hope I've been as specific as I can be. Thank you!
This error generally comes when there is some problem in your connection string. Try to check your connection string.
Also check this related forum. Hope that helps!

Suspended orchestration service instance re-throwing the same unexpected exception after Resume

I am getting below error, when i am trying to resume Suspended(resumable) orchestration instance.
Scenario: Request went thourgh DB2 Static solicit - Response port, and it got failed because of access permission denied. I can see two instances suspended in the admin console one is related to port and another one is related to orchestration. After fixing the credentials, suspended port instance got resumed but the orchestration one is keep on failing.
Uncaught exception (see the 'inner exception' below) has suspended an instance of service 'Orchestration name'.
The service instance will remain suspended until administratively resumed or terminated.
If resumed the instance will continue from its last persisted state and may re-throw the same unexpected exception.
InstanceId: ca927086-465d-40e8-93fe-c3a0e4c161f7
Shape name:
ShapeId:
Exception thrown from: segment -1, progress -1
Inner exception: An error occurred while processing the message, refer to the details section for more information
Message ID: {96B72521-9833-48EF-BB2F-4A2E2265D697}
Instance ID: {F6FBC912-C9DC-489C-87F3-103FA1273FDC}
Error Description: The user does not have the authority to access the host resource. Check your authentication credentials or contact your system administrator. SQLSTATE: HY000, SQLCODE: -1000
Exception type: XlangSoapException
Source: Microsoft.XLANGs.BizTalk.Engine
Target Site: Void VerifyTransport(Microsoft.XLANGs.Core.Envelope, Int32, Microsoft.XLANGs.Core.Context)
The following is a stack trace that identifies the location where the exception occured
at Microsoft.BizTalk.XLANGs.BTXEngine.BTXPortBase.VerifyTransport(Envelope env, Int32 operationId, Context ctx)
at Microsoft.XLANGs.Core.Subscription.Receive(Segment s, Context ctx, Envelope& env, Boolean topOnly)
at Microsoft.XLANGs.Core.PortBase.GetMessageIdForSubscription(Subscription subscription, Segment currentSegment, Context cxt, Envelope& env, CachedObject location)
at Microsoft.XLANGs.Core.PortBase.GetMessageId(Subscription subscription, Segment currentSegment, Context cxt, Envelope& env, CachedObject location)
at (StopConditions stopOn)
at Microsoft.XLANGs.Core.SegmentScheduler.RunASegment(Segment s, StopConditions stopCond, Exception& exp)
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
Any thoughts how to fix this?
Creating the above scenario using samples:
Go to BizTalk
samples/orchestrations/consumeWebservice
folder, install the
ConsumeWebService application and
publish POWebservice to IIS.
Change IIS Directory security
permissions for POWebservice, remove
anonymous or any other access.
Now drop the message you will see
suspended messages because of HTTP
status 401: Access Denied, then give
access to POWebservice either
anonymous or Windows.
Then resume
the suspended instances, one will
get disappear but
another(orchestration) one wont.
The orchestration will continue to fail with the exception because when it was suspended, the last persistence point was the receipt of the exception. This means that the orchestration will re-start (when resumed) and re-throw the exception.
Here's at article discussing some points at which orchestration state is persisted to the database: http://blogs.msdn.com/b/sanket/archive/2006/11/12/understanding-persistence-points-in-biztalk-orchestration.aspx
You can manipulate this to some extent in your orchestration design, as Richard Seroter discusses here, but generally you would do better to use failed message routing, enabling you to handle the failed messages, and terminate the failed orchestration instance.
Please correct me if I'm wrong, but is this not just normal biztalk behavior? I am not 100% sure so please let me know if this is wrong:
The outbound messaging instance was suspended because the credentials the port was using to connect to to the DB were wrong.
This caused the orchestrations making these calls to also suspend.
The suspended message instance was resumed and was processed correctly because the problem was fixed. So the call was made to the DB.
However, the orchestration instance may not be able to resume because when resumed it found itself at the most recent persistence point and the original error which was delivered back from the send port is still available to the orchestration, causing it to re-suspend.
In the error message, it actually says "If resumed the instance will continue from its last persisted state and may re-throw the same unexpected exception."
If you want to handle this sort of thing you could make the call to the database atomic. That way the orchestration will not persist itself at the point of making the DB call. If the orchestration then suspends it will resume at a point before the DB call is made, and will make the DB call as normal, which should succeed this time because you have fixed the original issue.
The only problem with this is if your DB call cannot be executed more than once with the same data without bad things happenning (is not idempotent).
I am not 100% on the above explaination. Please point out if my understanding is incorrect.
this scenario not treated by Microsoft Biztalk = Middleware FAIL.
you have to solve this at the orchestration design stage up front...
http://seroter.wordpress.com/2007/01/02/orchestration-handling-of-suspended-messages/

Resources