Exception From SendOptionAcknowledgementBase When errorMessage Is Null
Closed this issue · 2 comments
I have run into an issue where an unhandled exception is raised that terminates my program when the software I'm communicating with responds to an option acknowledgement with a TFTP Error with no message. I don't seem to be able to handle the exception from my code since it's raised from the context of the UdpChannel (BeginReceive) thread.
Sequence:
(Me => My Program with TFTP.NET)
(Them => The External Software)
Me:
Opcode: Option Acknowledgement (6)
Option: ...
Them:
Opcode: Error Code (5)
Error Code: Illegal TFTP Operation (4)
Message: 0x0 (NULL)
Here is the stack trace I see for this:
System.ArgumentException: You must provide an errorMessage.
at Tftp.Net.TftpErrorPacket..ctor(UInt16 errorCode, String errorMessage)
at Tftp.Net.Transfer.States.ReceivedError..ctor(TftpTransfer context, Error error)
at Tftp.Net.Transfer.SendOptionAcknowledgementBase.OnError(Error command)
at Tftp.Net.Error.Visit(ITftpCommandVisitor visitor)
at Tftp.Net.Transfer.States.StateThatExpectsMessagesFromDefaultEndPoint.OnCommand(ITftpCommand command, EndPoint endpoint)
at Tftp.Net.Trace.LoggingStateDecorator.OnCommand(ITftpCommand command, EndPoint endpoint)
at Tftp.Net.Transfer.TftpTransfer.connection_OnCommandReceived(ITftpCommand command, EndPoint endpoint)
at Tftp.Net.Channel.UdpChannel.RaiseOnCommand(ITftpCommand command, IPEndPoint endpoint)
at Tftp.Net.Channel.UdpChannel.UdpReceivedCallback(IAsyncResult result)
at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
at System.Net.ContextAwareResult.CompleteCallback(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.Net.ContextAwareResult.Complete(IntPtr userToken)
at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
at System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
THanks again for the analysis. I just merged your PR.