How can i host signalr on a dedicated server - signalr

I am working on a blazor application.
I have tried azure signalr services (ASRS).
All signalr requests are handled by a dedicated azure resource. So it suppose this reduce load on web server.
What i want to do is to deploy a dedicated signalr server like ASRS but on my own bare-metal server.
I have read some documentation about self-hosted azure but this is not the same thing than ASRS because ASRS does not host Hubs. Hubs stays on web server.
How can i do this ?
Thanks

Related

SignalR server to server communications

I have an application that uses SignalR to broadcast data to all connected clients. Its a .NET6 Blazor Wasm hosted web application. Now, I want the the broadcaster (which is running on the Blazor server) to connect to a data source that is outside my website, and get data from there. The source data is being broadcast via UDP on a different network.
So my question is, is it possible that my SignalR hub that is running on the Blazor server connects to another SignalR hub running on a different machine in a different network and get real time data from it? Or may be I can run a SignalR client as well on my Blazor server and then connect to a machine on another network? Can I run a SignalR hub on the UDP source machine to which my Blazor server SignalR hub or client can connect? From what I have read, SignalR only runs on a website. Or is it that SignalR is not suitable for this kind of server to server data feeds?

AWS Elasticbeanstalk WebSockets

I deployed an Asp.Net Web API project on Amazon Web Services' Elasticbeanstalk (IIS configured machine). Everything works fine except WebSocket. To test the WebSocket easier I use Simple WebSocket Client extension on Chrome.
When I make a request to the API, I get the following (error) message (I observe this message over developer console's network tab):
WebSocket connection to 'ws://my_url' failed: Error during WebSocket handshake: Unexpected response code: 400
I have not found enough information to overcome this problem.
I tried enabling all Inbound/Outbound TCP connections from all ports and all IPs under Security Groups.
I tried creating an empty Asp.Net Web API project that only has a basic sample of WebSockets (just sending a message to the connected user) and deploying it to a brand new environment and application on AWS.
Nothing has worked so far.
I am using Microsoft's WebSockets, .NET Framework 4.5.1.
What are the possible solution ways?
If you are using AWS Elastic Load Balancer in your elastic beanstalk then ELB does not support web sockets and you have to apply a work around. Change your Load Balancer top classic load balancer that supports Websockets.
https://aws.amazon.com/blogs/aws/new-aws-application-load-balancer/
I solved the problem by adding All TCP on Inbound segment of Security Groups and using the IP address of the server instead of AWS created name.

When we should use SignalR self hosted and when we should not?

I am in a stage of using SignalR in my project and i don't understand when to use Self hosted option and when we should not use. As a example if I am willing to host my web application in server farm,
There will be separate hosting servers
Separate SignalR hubs in each IIS server
If we want to broadcast message into each client, how this is working in SignalR
The idea with SignalR running in multiple instances is that clients connected on instance A cannot get messages from clients connected to instance B.
(SignalR scaleout documentation)
However, when you scale out, clients can get routed to different
servers. A client that is connected to one server will not receive
messages sent from another server.
The solution to this is using a backplane - everytime a server recieves a message, it forwards it to all other servers. You can do this using Azure Service Bus, Redis or SQL.
The way I see, you use the self host option when you either don't want the full IIS running (because you have some lightweight operations that don't require all IIS heaviness) or you don't want a web server at all (for example you want to add real-time functionality to an already existing let's say forms application, or in any other process).
Be sure to read the documentation for self-hosting SignalR and decide whether you actually need to self host SignalR.
If you are developing a web application under IIS, I don't see any reason why you would want to self-host SignalR.
Hope this helps. Best of luck!

Using ASP.NET Web application as SignalR client

My team is in the middle of deciding the architecture of our backend system:
Webserver A is an ASP.NET MVC application with ASP.NET Web API component, hosted in Azure Website.
Windows Service B is a self-hosted OWIN server that will periodically push notifications to clients who subscribes to the notification, hosted in Azure VM.
Windows Service C is a client that subscribes to notification from B, hosted in Azure VM.
Since we are more-or-less entrenched in .NET stack, we implemented B as SignalR server with C being the SignalR client. This part seems to work well.
Now comes a point where we also want A to subscribe to B, but I realize that it means an ASP.NET Web Server is going to act as SignalR CLIENT, instead of the typical scenario where it acts as SignalR server.
I presume we can initialize the SignalR connection in Global.asax and make the process ever-running to avoid AppDomain recycle. However, I feel a bit iffy when a Web Server is made to do something other than serving web requests. This solution also make the web server not stateless since it needs to maintain the web socket connection alive.
Is there something fundamentally wrong with making an ASP.NET application a SignalR client? Is there any possible gotcha with this setup?
In Azure you cannot tell that your AppDomain will not recycle. Because of many reasons, it can restart itself to heal and then you will end up making a new connection to the SingleR server. Is that OK for you?
Also SingleR is mostly used in the Web Functionality improvement where polling and refresh on web clients is made simple. But as your requirement seems to be all a back end stuff, I would suggest you to go with any other event driven pattern. Check Azure Service Bus topic/subscription model to have different components listen to various events and act accordingly.

should I use azure connect in this scenario

My webapplication hosted on windows azure needs to communicate with TFS Server.
my webroles connect to TFS using a uri similar to (http://ed12-ektfsp-01:8080/tfs/eeol/ )
While on azure I found that my webrole failed to communicate with tfs server.
Do I need to enable "azure connect" for for my azure webrole to
communicate with tfs ?
Do I need to remote into my tfs server and
install azure connect into my TFS server for the azure connect to
get enabled ?
Why azure cannot communicate using
"http://ed12-ektfsp-01:8080/tfs/eeol/ " ?
Your web application does not know the server ed12-ektfsp-01 (I'm assuming this is a server in your datacenter/in your internal network). But there are a few options to allow your web application to connect to this server even if it isn't hosted in Windows Azure:
Configure your firewall to allow traffic from the internet to reach the server ed12-ektfsp-01. This is probably something you do not want to do, unless the server is already available (maybe for developers working at home). Then instead of using the machine name, use the public domain instead (like tfs.mycompany.com) if it's available.
Like you already mentioned, use Windows Azure Connect. This allows you to create a secure tunnel between your roles and your datacenter/internal network. You'll be able to connect to ed12-ektfsp-01 even if it's not exposed to the internet through your firewall. In order for this to work you'll need to install the agent on each server you want to connect to your role, this includes your TFS server.
You can connect your role to a Virtual Network. Then you can use a VPN device on-premises to create a site-to-site VPN connection to this Virtual Network. See the tutorial here: Create a Virtual Network for Cross-Premises Connectivity
You can use Service Bus Relay. This allows you to create a WCF service that calls TFS and host that service within your datacenter/network, but publish it to the cloud. Your web application will be able to consume the WCF service as if it were hosted in Windows Azure.
Please take a look at my answer to this question.
As for your specific questions:
Do I need to enable "azure connect" for for my azure webrole to
communicate with tfs ?
YES.
Do I need to remote into my tfs server and install azure connect into
my TFS server for the azure connect to get enabled ?
YES. And add both the WebRole and the TFS Server into single Connection Group.
Why azure cannot communicate using
"http://ed12-ektfsp-01:8080/tfs/eeol/ " ?
Because the address given is known only within your corporate network, and only resolved by the Company's DNS server. Noone outside can access this address.

Resources