2

I struggle to connect my Blazor app to the new Aspire 9.1 Serverless SignalR emulator.

This is how I have configured my AppHost Program.cs:

var signalr = builder
    .AddAzureSignalR("signalr", AzureSignalRServiceMode.Serverless)
    .RunAsEmulator();

var hub = builder
    .AddAzureFunctionsProject<Projects.Entries_Hub>("hub")
    .WithReference(signalr)
    .WaitFor(signalr)
    .WithExternalHttpEndpoints()
    .WithHostStorage(storage);

The Entries.Hub project is an Azure Function. Here is a snippet of the Negotiate method:

    [Function("negotiate")]
    public async Task<HttpResponseData> Negotiate(
        [HttpTrigger(AuthorizationLevel.Anonymous, HubConstants.Post)] HttpRequestData req, CancellationToken cancellationToken)
    {
        var userId = req.Query["userId"];
        var negotiateResponse = await NegotiateAsync(new() { UserId = userId });
        var response = req.CreateResponse();
        await response.WriteBytesAsync(negotiateResponse.ToArray(), cancellationToken);
        return response;
    }

The emulator starts up properly in Docker:

e7e99b25940a9da0feeacd2fb8f5af03434a68fe5bb0de5fdc61e00172b707c6
Loaded settings from '/emulator/settings.json'. Changes to the settings file will be hot-loaded into the emulator.
warn: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[60]
      Storing keys in a directory '/root/.aspnet/DataProtection-Keys' that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed. For more information go to https://aka.ms/aspnet/dataprotectionwarning
warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
      No XML encryptor configured. Key {0225979c-fd8a-4662-a8c4-66e28a87a337} may be persisted to storage in unencrypted form.
warn: Microsoft.AspNetCore.Server.Kestrel[0]
      Overriding address(es) 'http://*:8080'. Binding to endpoints defined via IConfiguration and/or UseKestrel() instead.
 
===================================================
The Azure SignalR Emulator was successfully started.
 
Press Ctrl+C to stop the Emulator.
 
  TIPS: Use the below value inside *********** block as its ConnectionString:
 
 
***********
 
Endpoint=http://0.0.0.0;Port=8888;AccessKey=ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGH;Version=1.0;
 
***********
 
===================================================
 
Current Upstream Settings:
    [0]http://host.docker.internal:7071/runtime/webhooks/signalr(event:'*',hub:'*',category:'*')

This is the Exception in the Browser Console:

Mixed Content: The page at 'https://localhost:7164/' was loaded over HTTPS, but requested an insecure resource 'http://0.0.0.0:8888/client/negotiate?hub=notificationhub&negotiateVersion=1'. This request has been blocked; the content must be served over HTTPS.

What is the "trick" to connect with the Aspire Serverless SignalR emulator in Blazor?

I have been using the signalr emulator for a while. Everything works fine when starting it up manually. It is only when trying to use the new Aspire emulator that I get any errors.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.