FileTransferClient ConnectAsync results in ObjectDisposedException being logged

0 votes
asked Dec 5, 2019 by idblew (130 points)

We have an intermittent problem using async methods connecting to a particular FTP site.

The connection is initiated, however if no response is received from the server within the timeout period an ObjectDisposedException is logged to the LogWriter, but no exception is raised so our code continues and tries to login and transfer files (resulting in an exception but later in the code).

2019-12-04 23:12:47.196 INFO FileTransferClient(2152)[32] Info: Connecting to ftp.site.com:21 using Ftp.
2019-12-04 23:12:47.196 INFO FileTransferClient(2152)[32] Info: Assembly: Rebex.Ftp 2019 R4 for .NET Standard 2.0
2019-12-04 23:12:47.196 INFO FileTransferClient(2152)[32] Info: Platform: Linux 4.15.0-1063-azure #68-Ubuntu SMP Fri Nov 8 09:30:20 UTC 2019 64-bit; CLR: .NET Core 2.x (28207.03)
2019-12-04 23:12:47.196 INFO FileTransferClient(2152)[32] Info: Using proxy none.
2019-12-04 23:13:47.988 ERROR FileTransferClient(2152)[32] Info: System.ObjectDisposedException: Safe handle has been closed at System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean& success) at System.StubHelpers.StubHelpers.SafeHandleAddRef(SafeHandle pHandle, Boolean& success) at Interop.Sys.TryChangeSocketEventRegistration(IntPtr port, SafeHandle socket, SocketEvents currentEvents, SocketEvents newEvents, IntPtr data) at System.Net.Sockets.SocketAsyncContext.Register() at System.Net.Sockets.SocketAsyncContext.OperationQueue`1.StartAsyncOperation(SocketAsyncContext context, TOperation operation, Int32 observedSequenceNumber) at System.Net.Sockets.SocketAsyncContext.PerformSyncOperation[TOperation](OperationQueue`1& queue, TOperation operation, Int32 timeout, Int32 observedSequenceNumber) at System.Net.Sockets.SocketAsyncContext.Connect(Byte[] socketAddress, Int32 socketAddressLen) at System.Net.Sockets.SocketPal.Connect(SafeCloseSocket handle, Byte[] socketAddress, Int32 socketAddressLen) at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.Connect(EndPoint remoteEP) at qsqr.hlec(IPEndPoint qn) at qsqt.vtgm(EndPoint eyu) at Rebex.Net.ProxySocket.Connect(EndPoint remoteEP) at rliq..ctor(Ftp acm, String acn, Int32 aco) at Rebex.Net.Ftp.dbjz(String ez, Int32 fa, TlsParameters fb, SslMode fc, FtpSecureUpgradeType fd)

Is this a known issue or does somebody have example code for detecting this scenario?

Thanks
Ian

Applies to: Rebex FTP/SSL

1 Answer

+1 vote
answered Dec 5, 2019 by Lukas Pokorny (105,070 points)

This seems to be a bug. Thanks for reporting it! We'll look into it a send you a link to a hotfix when it's ready.

commented Dec 5, 2019 by idblew (130 points)
Hi Lukas,

Thanks for the prompt response, look forward to the hotfix!
commented Dec 9, 2019 by Lukas Pokorny (105,070 points)
I just sent a link to a hotfix to your e-mail. Please give it a try and let me know whether it solves the issue.
commented Dec 11, 2019 by idblew (130 points)
Looks good!

How soon before this will be available in a release?
commented Dec 11, 2019 by Lukas Pokorny (105,070 points)
This will be published with 2019 R4.1 release, which is currently undergoing testing and should be released next week.
...