AzureSignalR-samples
AzureSignalR-samples copied to clipboard
SignalR in Serverless Mode does not notify client when Application Server is down
We have a function app connecting to a SignalR resource in Azure set to Serverless mode.
The function app implements the negotiate function and sends + receives messages to our front end which is using the following package.
When the client disconnects, the function app receives an OnDisconnected message as expected. However, this does not work the other way around. When our function app is down the client continues to send service health check messages to the SignalR service which responds as still connected (type: 6).
The answer to this FAQ states that the client connections will be disconnected but we are seeing that it remains in the connected state until we attempt to send a message to the function app which results in this error 'Invocation failed, status code 403.
From the Front end perspective it does not know that the backend is unavailable and that it will no longer receive messages.
Its critical for our application that we can receive real time notifications and be notified if we are no longer receiving them so we can update the UI accordingly.
Please can someone let me know if this is the expected behavior and if this functionality is supported?
Many thanks
Hi @alexrickettsinnovationgroup , in serverless mode, we don't have notification when the function app is down, as the function app works as clients from the view of Azure SignalR Service. And that's why it is called serverless mode.
FYI: https://learn.microsoft.com/azure/azure-signalr/signalr-resource-faq#what-is-the-meaning-of-the--default----serverless---and--classic--service-modes--how-can-i-choose-
Thanks for your response @Y-Sindo.
Despite the name I wasn't aware of this behavior or even that we needed this requirement when we decided to add SignalR capabilities into one of our function apps.
My understanding is that we cannot simply switch to Default mode without significant code changes and even migrating the function to a Web App, can you confirm?
Do you have any suggestions or workarounds you can recommend?
My understanding is that we cannot simply switch to Default mode without significant code changes and even migrating the function to a Web App, can you confirm?
If you switch to default mode, you must migrate the workload in SignalR trigger to application servers, but SignalR output binding and input binding still work in function app, if that would help you reduce code changes. And I'm afraid there is no out-of-box solution to migrate function app to a Web App.
Ah so it is possible to use SignalR with a function app in default mode? I was under the impression function apps only work with serverless mode - can you confirm?
I haven't found examples of this in the samples, perhaps you could point me to one or explain what code changes would be required?
Although I would rather keep them I'm not precious about the bindings. I'm concerned specifically about needing to migrate to a web app and change all of our supporting pipelines + infrastructure.
Thanks again @Y-Sindo
Ah so it is possible to use SignalR with a function app in default mode?
I think theoretically it's possible if your function runtime is dotnet or dotnet isolated worker. You can try to add Azure SignalR service in your startup class like services.AddAzureSignalR() and see if there are other blockers. For dotnet isolated worker, it seems that you should also add a framework reference in your csproj file as follows :
<FrameworkReference Include="Microsoft.AspNetCore.App" />
We've settled on another workaround for now which is essentially sending a heartbeat message from the server to the connected connected clients on a timer.
My function is dotnet isolated so I will try what you have suggested when I have the opportunity to do so.
I will close this issue as it appears that the feature I am looking for is not supported with Serverless mode.
It would be really nice if something could be done in the future to let the client know that a connected server has disconnected but understand this may be not be suitable in Serverless mode.
Thanks again @Y-Sindo.