Skip to content

QUIC: QuicListener not reporting address in use correctly #73045

@JamesNK

Description

@JamesNK

Description

When two listeners are started on the same port, I get a generic error message instead of the address in use.

Note: this is on my local dev machine. I've seen S.N.Q report the right error message, e.g. dotnet/aspnetcore#42967

Reproduction Steps

See the unit test BindAsync_ListenersSharePort_ThrowAddressInUse added in dotnet/aspnetcore#42983

Expected behavior

QuicException has a status of AddressInUse and a friendly error message.

Actual behavior

ListenAsync throws this error: System.Net.Quic.QuicException : An internal error has occurred. ListenerStart failed: QUIC_STATUS_INVALID_STATE

Someone who gets that error message will have no idea what the problem is or how to fix it.

Full logs:

 Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.Tests.QuicConnectionListenerTests.BindAsync_AddressInUse_Log
   Source: QuicConnectionListenerTests.cs line 149
   Duration: 63 ms

  Message: 
System.Net.Quic.QuicException : An internal error has occurred. ListenerStart failed: QUIC_STATUS_INVALID_STATE

  Stack Trace: 
ThrowHelper.ThrowIfMsQuicError(Int32 status, String message)
QuicListener.ctor(QuicListenerOptions options)
QuicListener.ListenAsync(QuicListenerOptions options, CancellationToken cancellationToken)
QuicConnectionListener.CreateListenerAsync() line 122
QuicTransportFactory.BindAsync(EndPoint endpoint, IFeatureCollection features, CancellationToken cancellationToken) line 64
QuicTestHelpers.CreateConnectionListenerFactory(ILoggerFactory loggerFactory, ISystemClock systemClock, Boolean clientCertificateRequired, Int64 defaultCloseErrorCode, Int32 port) line 63
QuicConnectionListenerTests.BindAsync_AddressInUse_Log() line 156
QuicConnectionListenerTests.BindAsync_AddressInUse_Log() line 156
--- End of stack trace from previous location ---

  Standard Output: 
| [0.006s] TestLifetime Information: Starting test BindAsync_AddressInUse_Log at 2022-07-29T04:39:45
| [0.038s] Microsoft.AspNetCore.Server.Kestrel.Transport.Quic Debug: QUIC listener starting with configured endpoint 127.0.0.1:0.
| [0.062s] Microsoft.AspNetCore.Server.Kestrel.Transport.Quic Debug: QUIC listener starting with configured endpoint 127.0.0.1:65152.
| [0.072s] Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.Tests.QuicConnectionListenerTests Error: Test threw an exception.
| System.Net.Quic.QuicException: An internal error has occurred. ListenerStart failed: QUIC_STATUS_INVALID_STATE
|    at System.Net.Quic.ThrowHelper.ThrowIfMsQuicError(Int32 status, String message)
|    at System.Net.Quic.QuicListener..ctor(QuicListenerOptions options)
|    at System.Net.Quic.QuicListener.ListenAsync(QuicListenerOptions options, CancellationToken cancellationToken)
|    at Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.Internal.QuicConnectionListener.CreateListenerAsync() in C:\Development\Source\aspnetcore\src\Servers\Kestrel\Transport.Quic\src\Internal\QuicConnectionListener.cs:line 122
|    at Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.QuicTransportFactory.BindAsync(EndPoint endpoint, IFeatureCollection features, CancellationToken cancellationToken) in C:\Development\Source\aspnetcore\src\Servers\Kestrel\Transport.Quic\src\QuicTransportFactory.cs:line 64
|    at Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.Tests.QuicTestHelpers.CreateConnectionListenerFactory(ILoggerFactory loggerFactory, ISystemClock systemClock, Boolean clientCertificateRequired, Int64 defaultCloseErrorCode, Int32 port) in C:\Development\Source\aspnetcore\src\Servers\Kestrel\Transport.Quic\test\QuicTestHelpers.cs:line 63
|    at Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.Tests.QuicConnectionListenerTests.BindAsync_AddressInUse_Log() in C:\Development\Source\aspnetcore\src\Servers\Kestrel\Transport.Quic\test\QuicConnectionListenerTests.cs:line 156
|    at Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.Tests.QuicConnectionListenerTests.BindAsync_AddressInUse_Log() in C:\Development\Source\aspnetcore\src\Servers\Kestrel\Transport.Quic\test\QuicConnectionListenerTests.cs:line 156
|    at Xunit.Sdk.TestInvoker`1.<>c__DisplayClass48_1.<<InvokeTestMethodAsync>b__1>d.MoveNext() in C:\Dev\xunit\xunit\src\xunit.execution\Sdk\Frameworks\Runners\TestInvoker.cs:line 264
| --- End of stack trace from previous location ---
|    at Xunit.Sdk.ExecutionTimer.AggregateAsync(Func`1 asyncAction) in C:\Dev\xunit\xunit\src\xunit.execution\Sdk\Frameworks\ExecutionTimer.cs:line 48
|    at Xunit.Sdk.ExceptionAggregator.RunAsync(Func`1 code) in C:\Dev\xunit\xunit\src\xunit.core\Sdk\ExceptionAggregator.cs:line 90
| [0.074s] TestLifetime Information: Finished test BindAsync_AddressInUse_Log in 0.0711134s

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions