SignalR Hub: Unhandled exception - signalr

I've found the following error on the event viewer of my SignalR Server and I can't understand what could possibly cause that. Any tip?
An unhandled exception occurred and the process was terminated.
Exception: System.NullReferenceException
Message: Object reference not set to an instance of an object.
StackTrace: at Microsoft.AspNet.SignalR.Client.Transports.ServerSentEventsTransport.OnStartFailed()
at System.Action.Invoke()
at Microsoft.AspNet.SignalR.Client.Infrastructure.TransportInitializationHandler.<>c__DisplayClasse.<CompleteFail>b__d()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()

It's a bug. More details here. Currently assigned to be fixed in 2.2.1.

Judging by stack trace and the code in OnStartFailed() method I guess its some threading issue\race condition inside SignalR. Best you can do is probably report it at SignalR Github...

Related

How do I prevent or catch "Unable to run: socket is null" from AsterNet?

Using AsterNet to connect to Asterisk, I've been seeing the following:
Unhandled Exception:
System.SystemException: Unable to run: socket is null.
at AsterNET.Manager.ManagerReader.Run() in
e:\Projects\Github\AsterNET\Asterisk.2013\Asterisk.NET\Manager\ManagerReader.cs:line 197
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback,
Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state,
Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
You can see the line that throws this exception in the AsterNet code at ManagerReader.cs, line 197. It looks like this happens when connect() (in ManagerConnection.cs) launches a new thread, but mrSocket is somehow null in ManagerReader.cs. But this exception gets thrown from that new thread, so I can't catch it and handle the error. It just crashes my application.
So I have two questions. First, how do I prevent this from happening? Am I doing something wrong with how I connect or reconnect? Second, is it possible to catch this somehow and try the connection again?
This was happening because I was trying to maintain the connection myself and I didn't have to. I had written a loop to check the connection every so often and reconnect if it dropped and send pings to keep it alive. You can see an example of what I was doing here:
https://gist.github.com/squaregear/80821130d221727c3836dba3224bf93e
But I didn't need to do that. The current versions of AsterNet do all that for you. And when I was also trying to do it manually, it was interfering with the steps the library was taking. So the bottom line is, just let the AsterNet library maintain your connection for you.
You can see my discussion with the maintainers here:
https://github.com/AsterNET/AsterNET/issues/107

Using the HTTPClient and Sharepoint 2013 REST APIs to get Documents

I am working in a .NET web application.I am trying to connect to Sharepoint Online Premise to get documents in the "Document Library" by using the HTTPClient and the Sharepoint 2013 REST API .
I tested the following rest service in the browser for this ,
https://site_url/_vti_bin/ListData.svc/Documents
which gives the MetaData of all the documents present in the Document Library of the particular web site.
Now when i am trying to do the same programmatically by adding a reference to the service URL and by using the following code,
TestSiteDataContext ctx = new TestSiteDataContext(new Uri("https://site url/_vti_bin/ListData.svc"));
ctx.Credentials = new NetworkCredential("test#test.onmicrosoft.com", "test");
var data = ctx.Documents.ToList();
I am getting the following exception :
"The request was aborted: Could not create SSL/TLS secure channel."
The stack trace is as follows :
at System.Net.HttpWebRequest.GetResponse()
at System.Data.Services.Client.QueryResult.Execute()
at System.Data.Services.Client.DataServiceRequest.Execute[TElement](DataServiceContext context, QueryComponents queryComponents)
at System.Data.Services.Client.DataServiceQuery`1.Execute()
at System.Data.Services.Client.DataServiceQuery`1.GetEnumerator()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at SPO_AccessAWebService.Program.Main(String[] args) in Location\Program.cs:line 35
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
I have gone through various articles/blogs to find a solution for this.Bust couldn't find any.
I could see various samples tha shows authenticating by means of ,
ctx.Credentials = CredentialCache.DefaultNetworkCredentials;
This also is throwing the same error.
Is there is any other way to authenticate the SharePoint 2013 REST API?
Can someone provide me some insights to resolve this issue?
Based on the exception message you are reporting, it appears that the SSL cert is not valid for the site. I often see this message in development or test environments where self-signed cents are used. You should be able to tell if the cert is not valid if you have to click through a warning message when you visit the URL in a browser. To fix the issue, you can try connecting over http if transport security isn't a concern, obtain or install a valid cert, or import the current cert into Trusted Root Authorities store of the Current User or Local Machine.

Unable to serialize the session state

While executing a .aspx page i am getting the following error. Can you please let me know how can i solve it.
Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode.
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.Web.HttpException: Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode.
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:
[SerializationException: Type 'System.Web.UI.WebControls.DropDownList' in Assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable.]
System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type) +9472709
System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context) +247
System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo() +160
System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder) +491
System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo) +388
System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck) +444
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck) +133
System.Web.Util.AltSerialization.WriteValueToStream(Object value, BinaryWriter writer) +1762
[HttpException (0x80004005): Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode.]
System.Web.Util.AltSerialization.WriteValueToStream(Object value, BinaryWriter writer) +1847
System.Web.SessionState.SessionStateItemCollection.WriteValueToStreamWithAssert(Object value, BinaryWriter writer) +34
System.Web.SessionState.SessionStateItemCollection.Serialize(BinaryWriter writer) +638
System.Web.SessionState.SessionStateUtility.Serialize(SessionStateStoreData item, Stream stream) +244
System.Web.SessionState.SessionStateUtility.SerializeStoreData(SessionStateStoreData item, Int32 initialStreamSize, Byte[]& buf, Int32& length, Boolean compressionEnabled) +67
System.Web.SessionState.SqlSessionStateStore.SetAndReleaseItemExclusive(HttpContext context, String id, SessionStateStoreData item, Object lockId, Boolean newItem) +140
System.Web.SessionState.SessionStateModule.OnReleaseState(Object source, EventArgs eventArgs) +807
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +148
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
Thanks
Unable to serialize the session state. In 'StateServer' and
'SQLServer' mode, ASP.NET will serialize the session state objects,
and as a result non-serializable objects or MarshalByRef objects are
not permitted. The same restriction applies if similar serialization
is done by the custom session state store in 'Custom' mode.
This line is pretty telling. You need to mark objects with [Serializable] to serialize the object (the MSDN link contains more details about serializing the object graph).
In my case, I was trying to serialize the non-serialized object that is HttpResponse. So this couldn't help me.
Check this if this couldn't solve your problem: Asp.net serialization error for session state
This post save my time and solved my problem.
Add the following attribute to the offending class:
[Serializable()]
If that doesn't work then:
Consider using mode="InProc". I ran into this issue by switching to "SQLServer" and rolling back to "InProc". This might fix the issue because InProc doesn't require objects to be Serializable.
Which one is better, InProc or SQL Server, for Session State mode in asp.net?
[Serializable()]
public partial class CustomersMaintLog
{

ASP.NET error: IsBadPath() Object reference not set to an instance of an object

I'm getting an {"Object reference not set to an instance of an object."} exception randomly (it seems random) on a server. I can reproduce the exception using fiddler and my local machine by passing in no header data.
The stack trace is
at Microsoft.VisualStudio.WebHost.Request.IsBadPath()
at Microsoft.VisualStudio.WebHost.Request.TryParseRequest()
at Microsoft.VisualStudio.WebHost.Request.Process()
at Microsoft.VisualStudio.WebHost.Host.ProcessRequest(Connection conn)
at Microsoft.VisualStudio.WebHost.Host.ProcessRequest(Connection conn)
at Microsoft.VisualStudio.WebHost.Server.OnSocketAccept(Object acceptedSocket)
at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(_ThreadPoolWaitCallback tpWaitCallBack)
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)
any ideas? I can't get to the problematic code because No source available or symbols have not been loaded'.
ASP.NET 3.5
Looks like the unhandled leftovers from Response.Redirect call.
In my case this same problem happened because of invalid (too many?) cookies. I cleared the cookies and the problem went away.

When and why threading TimerCallback is triggered?

We have an asp.net application running on IIS6 with .net 2.0 (XP) that calls a web service in a button click event. It would take over 30 mins for web service to finish. But somehow after a certain period of time, usually between 20 ~ 30 mins, asp.net did another postback of button click event which cause problem in our application.
The track stack (see below) shows that postback was triggered by Threading.TimeCallback. Does anyone know why? or anything related to IIS setting?
Appreciated!
Michael
at ASP.platform_workflow_executeworkflow_aspx.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
at System.Web.HttpApplication.ApplicationStepManager.ResumeSteps(Exception error)
at System.Web.HttpApplication.ResumeStepsFromThreadPoolThread(Exception error)
at System.Web.HttpApplication.AsyncEventExecutionStep.ResumeStepsWithAssert(Exception error)
at System.Web.HttpApplication.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar)
at System.Web.HttpAsyncResult.Complete(Boolean synchronous, Object result, Exception error, RequestNotificationStatus status)
at System.Web.SessionState.SessionStateModule.PollLockedSessionCallback(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading._TimerCallback.PerformTimerCallback(Object state)
Could be a problem with the session timing out. Increasing the session timeout period could solve the problem.
However, with an operation running that long it might be better considering the WebService asynchronously and providing some information to the user while the process is running.

Resources