Comments (5)
Here is a sample project of my client code that fails. It's a blank Azure Function HTTP Trigger function project, into which I pasted a few lines of code that tries to connect to my local hub server.
My hub server seems to work when being connected to from the browser. I have some javascript that is using the @aspnet/signalr
package and it connects to my hub just fine.
from signalr.
I'm pretty sure Azure Functions are short lived "functions", so you can't have a traditional C# SignalR client running in them since they last for a single Http request basically.
Have you checked out the docs we have for the SignalR Service and Functions? https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-signalr-service
from signalr.
@BrennanConroy thank you for the quick reply!
I have checked those bindings out and they look super handy, but unfortunately we're currently targeting azure functions v1 because we need the .net framework support. I believe those bindings only work within a .net standard / core project, or possibly only on azure functions v2. I tried installing the package and got a whole host of compatibility errors. (Trust me, I put some serious thought into re-writing the whole thing to target Functions v2 and use .NET Core, but that involves finding replacements for some Windows-only third party libraries we use / pay for)
Alternatively, I tried directly accessing Azure SignalR Service, from my Functions code, via the REST API. I basically copy + pasted code from the serverless sample code on github that generates the JWT and puts together the HTTP request. This request seems to "go through", as I receive the "Accepted" HTTP response, but the message is never broadcast back out to other connected clients, it seems. I was having a difficult time debugging the REST API approach, so I attempted to revert back to the Microsoft.AspNetCore.SignalR.Client
package approach.
You're right that the functions are short lived. Is that not acceptable for SignalR? These functions don't need to receive anything, I'm just trying to broadcast-only some messages intended to be read by other connected signalr clients.
from signalr.
What @BrennanConroy says is true, that the Function is short-lived and really, the only way to use SignalR with Functions is the bindings. This short-livedness isn't really an applicable SignalR scenario; you could use the client to connect to a hub and send a message, but you'd be connecting/disconnecting quickly (which could lead to other issues). The idea of SignalR is always connected.
You are correct that these are for .NET Core only, I'm 99% sure. Adding @anthonychu to validate these are only for Core but I'm pretty sure they are.
Here's an idea - you could create a second function that responds to incoming HTTP requests, then effectively turns around and pumps those back into the service. Then, you could use the binding to pump the messages into the service, and your existing V1 function could simply make HTTP requests to your "realtime proxy function." That would also give you more ability to reuse the "realtime proxy" in other scenarios later if you need.
from signalr.
Thanks, @bradygaster.
I went ahead and introduced a second Functions application that target .NET Core and uses Functions V2. In that project I have a Service Bus-triggered Function that uses the SignalR output binding to dispatch messages to Azure SignalR service. That aspect of everything seems to be working now, as I can use Fiddler to log the HTTP requests and can see that the binding is indeed making the POST
request to Azure and is getting an Accepted
response.
I'm on to a whole new bit of confusion now though, as my browser-based @aspnet/signalr
clients are not receiving the messages that I'm invoking from the Azure Functions application via the SignalR binding. I go into detail about my setup and that issue in #3349 though.
from signalr.
Related Issues (20)
- Restarting TypeScript client does not resubscribe to subscriptions HOT 7
- After update today to VS 15.9 iOS not working HOT 11
- Rename Protocols.Json package to Protocols.NewtonsoftJson HOT 5
- Completion Message in Java client should not require result HOT 1
- [Java] Stream Item payload is an item, not a result HOT 1
- [Java] Crash when close a connections HOT 1
- Connection Fails with accented character in URL HOT 2
- SignalR not supported on Android 8.0.0 and higher HOT 2
- [JAVA] Concurrency and hub connection state HOT 9
- Consider using ReadWriteLock to protect HubConnctionState in Java client HOT 3
- SignalR client not running on android below 26 version HOT 11
- OnDisconnectedAsync(Exception exception) not fired (LongPooling) HOT 2
- Java Client: NullPointerException when calling hubConnection.stop(); HOT 1
- Is it possible to change Response cookies inside OnConnectedAsync? HOT 2
- [Android&Java] on network change HOT 1
- Java Streaming Support HOT 3
- [Issue] Benchmarking - Concurrent client messages HOT 10
- Feature: option to disable URL rewriting HOT 2
- I receive messages from my local Hub but not messages via Azure SignalR service HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from signalr.