PHD2->NINA Infrequent Hanging on Phd2 ReadLine after Start/Stop guiding command

Issue #496 resolved
Jonathan MacCollum created an issue

On rare occasions NINA and PHD2 end up in a deadlock where both applications become unresponsive.

NINA Version: 1.10.0.1060; x64; Windows 10

PHD2 Version 2.6.7

NINA returns responsiveness if PHD2 is killed, and the sequence is aborted.

One example shows the hanging to occur while reading from the TCP stream after a “StopGuiding” command is sent before slewing to a subsequent target in a sequence, and a fetch of PHD2’s application state is sent in reply:

[2020-04-17T04:12:59] [ERROR] [MemberName] WatchTaskAsync
[2020-04-17T04:12:59] [ERROR] [FileName] C:\data\NINA\code\NINA\Utility\NotifyTaskCompletion.cs
[2020-04-17T04:12:59] [ERROR] [Message] Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.IO.StreamReader.ReadBuffer()
at System.IO.StreamReader.ReadLine()
at NINA.Model.MyGuider.PHD2Guider.<SendMessage>d__54.MoveNext() in C:\data\NINA\code\NINA\Model\MyGuider\PHD2Guider.cs:line 384

  • -- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NINA.Model.MyGuider.PHD2Guider.<GetAppState>d__50.MoveNext() in C:\data\NINA\code\NINA\Model\MyGuider\PHD2Guider.cs:line 288

  • -- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NINA.Model.MyGuider.PHD2Guider.<StopGuiding>d__53.MoveNext() in C:\data\NINA\code\NINA\Model\MyGuider\PHD2Guider.cs:line 355

  • -- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NINA.ViewModel.Equipment.Guider.GuiderVM.<StopGuiding>d__29.MoveNext() in C:\data\NINA\code\NINA\ViewModel\Equipment\Guider\GuiderVM.cs:line 237

  • -- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NINA.ViewModel.SequenceVM.<StopGuiding>d__63.MoveNext() in C:\data\NINA\code\NINA\ViewModel\SequenceVM.cs:line 660

  • -- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NINA.ViewModel.SequenceVM.<SlewToTarget>d__58.MoveNext() in C:\data\NINA\code\NINA\ViewModel\SequenceVM.cs:line 580

  • -- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NINA.ViewModel.SequenceVM.<StartSequence>d__69.MoveNext() in C:\data\NINA\code\NINA\ViewModel\SequenceVM.cs:line 744

  • -- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NINA.ViewModel.SequenceVM.<StartSequencing>d__68.MoveNext() in C:\data\NINA\code\NINA\ViewModel\SequenceVM.cs:line 705

  • -- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at NINA.ViewModel.SequenceVM.<StartSequencing>d__68.MoveNext() in C:\data\NINA\code\NINA\ViewModel\SequenceVM.cs:line 727

  • -- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NINA.Utility.NotifyTaskCompletion`1.<WatchTaskAsync>d__5.MoveNext() in C:\data\NINA\code\NINA\Utility\NotifyTaskCompletion.cs:line 42

Comments (3)

  1. Jonathan MacCollum reporter

    Additional testing shows this deadlock situation occurs more than after sending a StopGuiding command. A session on the night of 2020-04-18 was successful without issue of any StopGuiding deadlock but after about the 4th slew encountered a deadlock after sending the StartGuiding command:

    The PHD2 application was terminated leaving the following exception being thrown in nina to point out the stack of the deadlock:

    [2020-04-19T02:45:36.4968] [ERROR] [MemberName] WatchTaskAsync
    [2020-04-19T02:45:36.4968] [ERROR] [FileName] U:\data\NINA\code\NINA\Utility\NotifyTaskCompletion.cs
    [2020-04-19T02:45:36.4968] [ERROR] [Message] Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
    at System.IO.StreamReader.ReadBuffer()
    at System.IO.StreamReader.ReadLine()
    at NINA.Model.MyGuider.PHD2Guider.<SendMessage>d__54.MoveNext() in U:\data\NINA\code\NINA\Model\MyGuider\PHD2Guider.cs:line 400
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at NINA.Model.MyGuider.PHD2Guider.<<StartGuiding>g__TryStartGuideCommand|52_0>d.MoveNext() in U:\data\NINA\code\NINA\Model\MyGuider\PHD2Guider.cs:line 318
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at NINA.Model.MyGuider.PHD2Guider.<StartGuiding>d__52.MoveNext() in U:\data\NINA\code\NINA\Model\MyGuider\PHD2Guider.cs:line 330
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at NINA.ViewModel.Equipment.Guider.GuiderVM.<StartGuiding>d__31.MoveNext() in U:\data\NINA\code\NINA\ViewModel\Equipment\Guider\GuiderVM.cs:line 239
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at NINA.ViewModel.SequenceVM.<StartGuiding>d__71.MoveNext() in U:\data\NINA\code\NINA\ViewModel\SequenceVM.cs:line 690
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at NINA.ViewModel.SequenceVM.<StartSequence>d__78.MoveNext() in U:\data\NINA\code\NINA\ViewModel\SequenceVM.cs:line 801
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at NINA.ViewModel.SequenceVM.<StartSequencing>d__77.MoveNext() in U:\data\NINA\code\NINA\ViewModel\SequenceVM.cs:line 743
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at NINA.ViewModel.SequenceVM.<StartSequencing>d__77.MoveNext() in U:\data\NINA\code\NINA\ViewModel\SequenceVM.cs:line 765
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at NINA.Utility.NotifyTaskCompletion`1.<WatchTaskAsync>d__5.MoveNext() in U:\data\NINA\code\NINA\Utility\NotifyTaskCompletion.cs:line 42

  2. Log in to comment