Base solution for your next web application
Open Closed

Azure SignalR Integration #12372


User avatar
0
ricardo created

Hello friends,

We are having trouble integrating Azure SignalR. Messages are rarely displayed. I tested both locally and hosting on Azure AppService. In App Service we have three instances, and we have also configured Redis as a cache.

we use aspNetCore MVC

my settings:
Startup.png

we get no connection errors:
ClientConectLog.png
BrowserConectLog.png

We use Azure LiveTrace to retrieve the logs:

https://docs.google.com/spreadsheets/d/17YxfG-FxYLug1UzvVwNLEAncFlvGvBCp/edit?usp=sharing&ouid=105538182826738653593&rtpof=true&sd=true

running locally no messages are delivered. Publishing to the Azure service we randomly receive some messages.

When we remove the Azure SignalR service the messages arrive normally.


5 Answer(s)
  • User Avatar
    0
    oguzhanagir created
    Support Team

    Hi @ricardo

    The default operating mode for Azure SignalR might be "default". However, if you are running in "serverless" mode, SignalR only sends messages via REST APIs or Azure Functions and does not support WebSocket connections.

    Please ensure that this setting is defined as "Default" or "Classic". Add the ServerStickyMode setting as well

    services.AddSignalR().AddAzureSignalR(options =>
    {
        options.ServerStickyMode = ServerStickyMode.Required;
    });
    

    Can you check this situation?

  • User Avatar
    0
    ricardo created

    Hi @oguzhanagir,

    thanks for the feedback.

    we check the configuration in azure:
    Azure.png

    We added the configuration:
    NOvaConfig.png

    When we test it by running it locally in debug pointing to the azure signal R service, it works:

    both users appear online and messages are displayed instantly.

    But when we publish to the Azure Application Service we still don't receive it, or it does so very randomly:

    the logs received in the trace indicate that the messages are arriving at the azure service. But for some reason they are not being delivered.
    Trace.png

    in production we are using the Redis cache:
    Redis.png

    Should I do any additional configuration in Redis?

  • User Avatar
    0
    ricardo created

    Hi @oguzhanagir,

    we did some more tests, and when we disabled the usePerRequestRedisCache option everything works again as expected. But everything is very slow because we don't have cache per request.

    We noticed that the implementation of usePerRequestRedisCache does not contain iocManager.RegisterIfNot<IOnlineClientStore, RedisOnlineClientStore>();

    PerRequestConfig:
    PerRequest.png

    Redis Config:
    RedisConfig.png

    So when we use usePerRequestRedisCache, the OnlineClientStore is not stored in the Redis cache, which is probably causing issues when sending messages

    Can you check why IOnlineClientStore, RedisOnlineClientStore is not implemented when we use usePerRequestRedisCache option?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    You are right. I have created an issue and we will release a version in a short time. Please follow https://github.com/aspnetboilerplate/aspnetboilerplate/issues/7119

  • User Avatar
    0
    ricardo created

    Hi,

    thanks