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

Catch BeginConnect exceptions in TcpConnection #1047

Merged
merged 1 commit into from
Nov 10, 2021
Merged

Catch BeginConnect exceptions in TcpConnection #1047

merged 1 commit into from
Nov 10, 2021

Conversation

xPaw
Copy link
Member

@xPaw xPaw commented Nov 10, 2021

https://docs.microsoft.com/en-us/dotnet/api/system.net.sockets.socket.beginconnect

I've had my program crash with SocketException (albeit with no useful stacktrace directly pointing to this line), and looking at the other connection failures above it appears to be this.

@yaakov-h
Copy link
Member

.NET Framework and .NET 5 and earlier only: An error occurred when attempting to access the socket.

You could fix it by upgrading to .NET 6 😂

@yaakov-h yaakov-h added the bug label Nov 10, 2021
@yaakov-h yaakov-h added this to the 2.4.0 milestone Nov 10, 2021
@xPaw
Copy link
Member Author

xPaw commented Nov 10, 2021

You could fix it by upgrading to .NET 6 😂

This was on NET 6

@xPaw
Copy link
Member Author

xPaw commented Nov 10, 2021

After brief digging, this appears to be a .NET6 regression. So this PR likely won't fix it, but it's still useful as BeginConnect can throw other exceptions.

Here's the full trace:

Unhandled exception. System.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. (Operation canceled) (Operation canceled)
 ---> System.Net.Sockets.SocketException (125): Operation canceled
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
   at System.Threading.Tasks.ValueTask.ValueTaskSourceAsTask.<>c.<.cctor>b__4_0(Object state)
   --- End of inner exception stack trace ---
   at System.AggregateException.Handle(Func`2 predicate)
   at SteamDatabaseBackend.Bootstrapper.OnUnobservedTaskException(Object sender, UnobservedTaskExceptionEventArgs args) in /home/steamdb/deploy/Bootstrapper.cs:line 149
   at System.Threading.Tasks.TaskScheduler.PublishUnobservedTaskException(Object sender, UnobservedTaskExceptionEventArgs ueea)
   at System.Threading.Tasks.TaskExceptionHolder.Finalize()

@yaakov-h yaakov-h merged commit ef20df8 into SteamRE:master Nov 10, 2021
@xPaw xPaw deleted the beginconnect-exception branch November 10, 2021 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants