question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Azure SignalR Integration IAsyncCollector equivalent?

See original GitHub issue

We use the SignalR integration with Azure Functions using the IAsyncCollector output binding

[FunctionName("SendMessage")]
public static Task SendMessage(
    [HttpTrigger(AuthorizationLevel.Anonymous, "post")]object message,
    [SignalR(HubName = "chat")]IAsyncCollector<SignalRMessage> signalRMessages)
{
    return signalRMessages.AddAsync(
        new SignalRMessage
        {
            // the message will only be sent to these user IDs
            UserId = "userId1",
            Target = "newMessage",
            Arguments = new [] { message }
        });
}

In attempting to migrate over I tried changing the AsyncCollector over to OutputBinding<SignalRMessage>, but using this only the last message added is actually sent. Is there a way to send multiple messages as the process is running?

[FunctionName("SendMessage")]
public static Task SendMessage(
    [HttpTrigger(AuthorizationLevel.Anonymous, "post")]object message,
    [SignalR(HubName = "chat")]OutputBinding<SignalRMessage> signalRMessages)
{
    return signalRMessages.AddAsync(
        new SignalRMessage
        {
            // the message will only be sent to these user IDs
            UserId = "userId1",
            Target = "newMessage",
            Arguments = new [] { message }
        });
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
fabiocavcommented, Feb 26, 2021

@anthonychu I think this is actually about two different things (@sccrgoalie1 , please correct me if I’m wrong), both about the cardinality (sending multiple messages) and the real time behavior of the async collector provided by the SignalR extension. The latter will not be addressed by GA (messages will only be sent when the function returns)

1reaction
anthonychucommented, Feb 12, 2021

You should be able to use OutputBinding<IEnumerable< SignalRMessage >> but this is not working in preview3. Tracking this here: https://github.com/Azure/azure-functions-dotnet-worker/issues/124

Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure WebJobs SignalR Service client library for .NET
Azure SignalR resource: To use SignalR Service client library ... the SignalR attribute to the IAsyncCollector<SignalRMessage> parameter.
Read more >
Azure Function SignalR Output Binding - How to receive ...
My environment: 1 - Azure Function which does some work and then sends a message to the SignalR service. 2 - A NET...
Read more >
Replace Signal R with Azure Signal R #9976
I am using "@microsoft/signalr": "^5.0.1",. Everything just works for me. Also @ismcagdas is talking about the config files in the angular ...
Read more >
Serverless real-time messaging with Azure Functions and ...
This function will be called to broadcast a message to all connected clients through our SignalR Service. Therefore we will create a new ......
Read more >
Using the Azure SignalR Service Bindings in ...
The Azure SignalR Service is a serverless offering from Microsoft to facilitate real-time communications without having to manage the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found