Rebex Library: Latest on nuget
My scenario is this. I have a FileTransferClient mClient connecting to an FTP server where the username is set, but the password is incorrect. What I am seeing is that mClient.LoginAsync does not throw. It happily returns with IsAuthenticated = false. Later on I get an UnobservedTaskException in my UnobservedTaskException handler with the following stack trace:
021-11-19 14:47:14.6287 (5156.2) Debug [Initializer] Unexpected logic error [AggregateException] A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread.
-->[FtpException] Login or password incorrect! (530).
--> at Rebex.Net.Ftp.aqhpm(String p0, String p1, String p2)
--> at Rebex.Net.Ftp.jnmvq(Object p0, Enum p1, Object p2)
--> at owtsr.ucnia.nmvkt(Object p0). Please contact
await m_Client.ConnectAsync(m_Configuration.Host, m_Configuration.Port.Value,(FileTransferMode) m_Configuration.FileTransferType);
// this is not throwing when there is a login error
await m_Client.LoginAsync(m_Configuration.User, m_Configuration.Password);
What I am assuming is happening is that your library is not awaiting a task inside LoginAsync. The language in the help documention for LoginAsync seems to imply that this is only beginning an async operation which is not what one would expect from an Async method. Perhaps this is a hold-over from when this was BeginLogin?
"Begins asynchronous Login operation. Authenticates the user to the FTP server."
Lastly, if I replace mClient.LoginAsync with the sync mClient.Login, I get an exception thrown as one would expect. I would expect that awaiting LoginAsync should have the same behavior as the sync method Login.
Could you please have a look at this and let me know if I should be doing something differently.