You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
In SocketConnectionInitiator when cannot connect to server SocketException occurs, but due to incorrect handling instead of processing that exception NullReferenceException is thrown which is confusing
lastException is null if there is any exception in CreateConnectionAsync:
So further in ConvertConnectException we shouldn't check for lastException or check if it's not null and check innerException instead:
See NullReferenceException when using invalid path instead of more meaningful error
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
at System.ServiceModel.Channels.SocketConnectionInitiator.ConvertConnectException(SocketException socketException, Uri remoteUri, TimeSpan timeSpent, Exception innerException)
at System.ServiceModel.Channels.SocketConnectionInitiator.ConnectAsync(Uri uri, TimeSpan timeout)
at System.ServiceModel.Channels.BufferedConnectionInitiator.ConnectAsync(Uri uri, TimeSpan timeout)
at System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnectionAsync(TimeSpan timeout)
at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpenAsync(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.OnOpenAsyncInternal(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.System.ServiceModel.IAsyncCommunicationObject.OpenAsync(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.OnOpenAsync(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.OnOpenAsyncInternal(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.System.ServiceModel.IAsyncCommunicationObject.OpenAsync(TimeSpan timeout)
at System.Runtime.TaskHelpers.WaitForCompletion(Task task)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open()
at System.ServiceModel.Channels.ServiceChannelProxy.System.ServiceModel.ICommunicationObject.Open()
at Program.<Main>$(String[] args) in C:\Users\user\Desktop\ExceptionSample\ExceptionSample\Program.cs:line 15
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered:
DenisDoroshko
changed the title
[Bug] NullReferenceException in SocketConnectionInitiator when cannot connect to server instead of meaningful error
[Bug] NullReferenceException in SocketConnectionInitiator for UnixDomainSocket when cannot connect to server instead of meaningful error
Feb 27, 2024
@imcarolwang can you please investigate and come up with a PR? Please make sure it throws EndPointNotFound exception, the call to ConvertConnectException should pass in SocketException, not lastException, and add unit test as well.
Describe the bug
In
SocketConnectionInitiator
when cannot connect to serverSocketException
occurs, but due to incorrect handling instead of processing that exceptionNullReferenceException
is thrown which is confusinglastException
is null if there is any exception inCreateConnectionAsync
:So further in ConvertConnectException we shouldn't check for
lastException
or check if it's not null and checkinnerException
instead:To Reproduce
Steps to reproduce the behavior:
ExceptionSample.zip
NullReferenceException
when using invalid path instead of more meaningful errorVideo demo:
https://github.com/dotnet/wcf/assets/71182505/cf649b99-29c1-4804-b9ef-5b426e952a9f
Expected behavior
NullReferenceException shouldn't happen and SocketException should be processed in some way.
Screenshots
If applicable, add screenshots to help explain your problem.
Exception in https://github.com/dotnet/wcf/blob/main/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/SocketConnection.cs#L792
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: