simongh / Discovery

Discovery library for .Net
MIT License
12 stars 3 forks source link

Unhandled Null Reference Exception #2

Open shaneh20 opened 5 years ago

shaneh20 commented 5 years ago

Hi, I've been using your nice library for a while now and just today we had an issue where we couldn't start one of our windows services that is using this ssdp lib. It was crashing with an unhandled exception being logged in Event Viewer:

Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.NullReferenceException at Discovery.SSDP.MessageParser.GetNotifyMessage(System.Collections.Generic.List`1) at Discovery.SSDP.MessageParser.Parse(Byte[]) at Discovery.SSDP.Agents.AgentBase.ParseResponse(System.Object) at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(System.Object) at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() at System.Threading.ThreadPoolWorkQueue.Dispatch() at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

I've got a feeling there might be some other SSDP software on our network that is trying to discover its server by broadcasting out the "M-SEARCH * HTTP/1.1" string on port 1900. Looking at your code in the MessageParser class it looks like this might be causing the issue in GetNotifyMessage.

Changing this ssdp lib to use a different port fixed the problem, so it looks like when it uses the default 1900 port it's not handling messages received from other SSDP clients properly.

simongh commented 5 years ago

Thanks for taking the time to get in touch with me. I think i noticed this bug when working on a new version. I'll take a look & see if I can track down the issue.

Thanks again

Simon

On Wed, 27 Mar 2019 at 01:44, shaneh20 notifications@github.com wrote:

Hi, I've been using your nice library for a while now and just today we had an issue where we couldn't start one of our windows services that is using this ssdp lib. It was crashing with an unhandled exception being logged in Event Viewer:

Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.NullReferenceException at Discovery.SSDP.MessageParser.GetNotifyMessage(System.Collections.Generic.List`1) at Discovery.SSDP.MessageParser.Parse(Byte[]) at Discovery.SSDP.Agents.AgentBase.ParseResponse(System.Object) at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(System.Object) at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() at System.Threading.ThreadPoolWorkQueue.Dispatch() at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

I've got a feeling there might be some other SSDP software on our network that is trying to discover its server by broadcasting out the "M-SEARCH * HTTP/1.1" string on port 1900. Looking at your code in the MessageParser class it looks like this might be causing the issue in GetNotifyMessage.

Changing this ssdp lib to use a different port fixed the problem, so it looks like when it uses the default 1900 port it's not handling messages received from other SSDP clients properly.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/simongh/Discovery/issues/2, or mute the thread https://github.com/notifications/unsubscribe-auth/ABZ7T-sf4dZCJpMHwpfS_C1UMLKU8-dmks5vas0RgaJpZM4cMx2j .