Azure / azure-signalr

Azure SignalR Service SDK for .NET
https://aka.ms/signalr-service
MIT License
427 stars 101 forks source link

ClientManager.ConnectionExistsAsync throws exception on expected 404 response from emulator #1912

Closed vyacheslav-sozap closed 3 months ago

vyacheslav-sozap commented 9 months ago

Describe the bug

I'm calling "Microsoft.Azure.SignalR.Management.ClientManager.ConnectionExistsAsync" for non-existing connection, while talking to emulator. Method call throws exception, saying that emulator responded "404", but it seems like expected behaviour, so I guess method call shouldn't throw exception. Debugging deeply, I see that response doesn't contain header "x-ms-error-code", which management sdk is expecting, so it might be an emulator issue though.

Tested with azure cloud SignalR, works fine, not throwing exception, so problem is probably in the emulator.

To Reproduce

  1. Run emulator
  2. Create CLI app with "Microsoft.Azure.SignalR.Management" referenced
  3. Create instance of ServiceHubContext
  4. Call hubContext.ClientManager.ConnectionExistsAsync("non_existing_connection");

Exceptions

Microsoft.Azure.SignalR.Common.AzureSignalRInaccessibleEndpointException: Unable to access SignalR service. Response status code does not indicate success: 404 (Not Found) Please make sure the endpoint or DNS setting is correct. Request Uri: http://localhost:8888/api/hubs/signalrhub/connections/xxxxxxxxxxxxxxxxxxxxxx?api-version=2022-06-01
 ---> System.Net.Http.HttpRequestException: Response status code does not indicate success: 404 (Not Found)
   --- End of inner exception stack trace ---
   at Microsoft.Azure.SignalR.RestClient.ThrowExceptionOnResponseFailureAsync(HttpResponseMessage response) in ...\azure-signalr-1.24.0\src\Microsoft.Azure.SignalR.Common\Utilities\RestClient.cs:line 106
   at Microsoft.Azure.SignalR.RestClient.SendAsyncCore(String httpClientName, RestApiEndpoint api, HttpMethod httpMethod, String methodName, Object[] args, Func`2 handleExpectedResponseAsync, CancellationToken cancellationToken) in ...\azure-signalr-1.24.0\src\Microsoft.Azure.SignalR.Common\Utilities\RestClient.cs:line 138
   at Microsoft.Azure.SignalR.Management.RestHubLifetimeManager`1.ConnectionExistsAsync(String connectionId, CancellationToken cancellationToken) in ...\azure-signalr-1.24.0\src\Microsoft.Azure.SignalR.Management\RestHubLifetimeManager.cs:line 273
   ...

Further technical details