-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SignalRTrigger not working for either connection or messages category #1122
Comments
Did you get some log when triggering functions from Azure Function side or client side.
|
Hi I didn't have any errors in logs. Triggers were not causing my functions to run, that's it. There are no filters or settings above the connection string and CORS to test it. {
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"AzureSignalRConnectionString": "Endpoint=http://localhost;Port=8088;AccessKey=ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGH;Version=1.0;",
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
},
"Host": {
"LocalHttpPort": 7071,
"CORS": "http://localhost:5500",
"CORSCredentials": true
}
} Please see the repo: https://github.com/Artur-Biniek/SignalRTriggerNotWorking Backend code is in Function1.cs. There are negotiate & send functions that work. The other two do not. I'd expect when different clients join and disconnect the warning logs to be printed (and breakpoints to be hit): https://github.com/Artur-Biniek/SignalRTriggerNotWorking/blob/ba19d12db2e384ae2a5fb84b7a943bf7cd39f94b/Backend/RealTimeTestZero/Function1.cs#L50 But they're not. I couldn't see anything in the official documentation that would say those shouldn't work in this scenario. FYI: the local func runtime seems to pick up those triggers and report them on the startup. Even displays them in different color to "normal" functions. |
I'm having the same problem. Using MSI. |
Is this declaration correct? [FunctionName("OnConnected")] both methods that aren't working have that sig |
Same issue here, against production SignalR service, tried both approaches (class and trigger), as explained in https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-signalr-service-trigger?tabs=csharp#with-class-based-model |
@stemixreal If you're using class-based model. You need to use non-static method. And the method name should be OnConnected rather than FunctionName. Please refer to https://github.com/aspnet/AzureSignalR-samples/blob/9c16f7cc98ef38b8433251b2466ecd5bd0746418/samples/BidirectionChat/csharp/Function.cs#L37 |
OnConnected is not easy for troubleshooting. Please set a method like broadcast in Azure Function and invoke it from client. You should get an error from browser console. The status code you get comes from the invoke between service and your function. And I suggest you enabling Diagnostic Log in the service. You can see the reason why the invoke is failed. |
Any progress on this? I don't get any connection, broadcast or disconnected event too. Using Microsoft.Azure.WebJobs.Extensions.SignalRService Version="1.8.0". |
@agravity-philipp Did you check all the points that @zackliu mentioned? You could also use live trace tool to have a check. |
Hi @Y-Sindo ! Thanks for sharing that tool. Unfortunatly it doesn't help much. I didn't find any (working) samples on serverless SignalR "connected" event trigger. None of the above mentioned or other samples on GitHub or StackOverview are working... If I do
I get this message: Don't get me wrong. SignalR is working with all my clients, with grouping, direct messaging to users etc. But I just don't get the trigger on (new) connections. This did not work too:
|
For this sample: [FunctionName(nameof(OnConnected))]
public async Task OnConnected([SignalRTrigger("HubName", "connections", "connected")] InvocationContext invocationContext, ILogger logger)
{
invocationContext.Headers.TryGetValue("Authorization", out var auth);
// await Clients.All.SendAsync(NewConnectionTarget, new NewConnection(invocationContext.ConnectionId, auth));
logger.LogInformation($"{invocationContext.ConnectionId} has connected");
} As the error message says, you should remove all the parameters of the There is a sample with connected trigger mentioned here. In class-based model, as long as your function name is "OnConnected", that function is recognized as a connected trigger, and the hub name is the class name where your functions belong to. Therefore, there is no need to add parameters Please tell me if you have any problem after checking the sample. |
Is there any update to this issue? We are facing the exact same issue in 2023. |
@marcusfalck83 We keep this issue open just to help users to find troubleshooting methods of SignalR trigger easier. If the troubleshooting guide here doesn't work for you, please open a new issue and provide more information for us to help you. |
Close as cannot repro |
For users who have trouble with SignalR trigger, following docs might help you: |
For users who have trouble with SignalR trigger, following docs might help you: |
Describe the bug
SignalRTrigger attribute with category set to either messages or connection is not invoking azure function when client connects/disconnects/calls client side connection.invoke("medhodName", params).
To Reproduce
// negotiate function (not shown here), works, also sending messages to connected clients via HTTPTriggered function also works. Tested both with class based and triggers approach. Tested on real Azure SignalR service and on local emulator from the preview package (asrs-emulator)
func sdk discovers triggers:
Azure Functions Core Tools
Core Tools Version: 3.0.2996 Commit hash: c54cdc36323e9543ba11fb61dd107616e9022bba
Function Runtime Version: 3.0.14916.0
[2020-11-22T13:09:17.297Z] Unsupported service transport type: . Use default Transient instead.
Functions:
Exceptions (if any)
Further technical details
Server Side:
TargetFramework: netcoreapp3.1
AzureFunctionsVersion: v3
"Microsoft.Azure.WebJobs.Extensions.SignalRService" Version="1.2.2"
"Microsoft.NET.Sdk.Functions" Version="3.0.11"
Client side:
<script src="https://cdnjs.cloudflare.com/ajax/libs/microsoft-signalr/3.1.7/signalr.min.js"></script>
The text was updated successfully, but these errors were encountered: