Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#770 Fix unobserved SocketException #771

Closed

Conversation

nmandzyk
Copy link
Contributor

@nmandzyk nmandzyk commented May 8, 2023

#770 Perform socket read operations according to Task-based asynchronous pattern (TAP) instead of Asynchronous Programming Model (APM)

  • fix unobserved SocketException

@CLAassistant
Copy link

CLAassistant commented May 8, 2023

CLA assistant check
All committers have signed the CLA.

…asynchronous pattern (TAP) instead of Asynchronous Programming Model (APM)

- fix unobserved  SocketException
@nmandzyk nmandzyk force-pushed the feature/770_unobserved_excpetions branch from a66df9b to 7ba1abb Compare May 8, 2023 22:39
_readCancellationTokenSource?.Dispose();
_readCancellationTokenSource = null;

// just wait when read task will be cancelled
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the unobserved SocketExceptions were coming from closing the stream when disconnecting, and now we are cancelling the read with the CancellationTokenSource, and the ContinueWith is there to swallow the resulting OperationCanceledException on the Task. Is that right? Perhaps it is worth expanding the comment?

Suggested change
// just wait when read task will be cancelled
// The ContinueWith observes (and swallows) the resulting
// OperationCanceledException on the task.
// This avoids unobserved exceptions appearing elsewhere
// (which we ultimately don't care about during disconnect)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Rob-Hague . I am sorry for the delayed response. Not exactly. The unobserved exception was triggered when we call .BeginRead(...) and the other side just closed the connection. I reimplemented the socket reading based on Begin/End async approach to the task-based approach that will raise the exception on task awaits.
About the ContinueWith you are absolutely right.

@gbirchmeier
Copy link
Member

This looks promising, as do a few other recent PRs by you and others.

I'm working to put out a new release right now. It will not include this, but I'm going to see if I can improve our process internally so we can start moving on a lot of these PRs for the next release after this (and have these releases come out on a more frequent bases).

gbirchmeier pushed a commit to gbirchmeier/quickfixn that referenced this pull request Feb 14, 2024
resolves connamara#770 (original issue)
resolves connamara#771 (original PR, this is a rebase)

Perform socket read operations according to Task-based asynchronous pattern (TAP) instead of Asynchronous Programming Model (APM)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants