Does each SignalR hub has a dedicated websocket - websocket

Assuming both browser & Server supports a web-socket connection.
If I've got 2 hubs on my SignalR server. and my SignalR client connects to both. does that mean that my signalR client will open up 2 separate web-socket connections to the server?

In SignalR v2+, hubs will share the same connection. I've had systems with connections to 4+ hubs without performance issue.
Question is a bit of a duplicate of: Multiple signalR connections/hubs on your website

Related

API Server as SignalR client

I've got an ASP.NET MVC Core application which is served from a web server. The web server has a SignalR Hub and gets its data from a dedicated API server. Is it possible to register the web clients AND the API server as SignalR clients, so that the API server can push data directly to the web clients?
Yes. From the same host, inject a IHubContext<YourHub> into your controller classes and from there you can send messages to any connected clients, see more here: https://learn.microsoft.com/en-us/aspnet/core/signalr/hubcontext.
From a different host, use the SignalR client, see here: https://learn.microsoft.com/en-us/aspnet/core/signalr/dotnet-client.

what are EIO=3&transport=websocket in websocket url

wss://www.mysite.ca/socket.io/?EIO=3&transport=websocket
This is how chrome webdevoloper tools shows the request url of a socket io.
I am trying to understand more about EIO=3&transport=websocket .
I have to invoke the url from an API tool
These are query parameters that the socket.io client sends to the socket.io server as part of the initial connection request.
EIO=3, I believe, is the version number of the engine.io sub-system in socket.io. If the server is not compatible with this version number, it will likely fail the attempt to connect.
transport=websocket says that socket.io wants to use the websocket protocol as the eventual transport. socket.io has several different transports it supports including web polling and a flash-based protocol.
To connect to socket.io server, you will need a full-fledged socket.io client. You can't make a socket.io connection by just sending a URL from a tool to the server. There's a lot more involved than that in establishing a working socket.io connection.

Xamarin messaging by Websockets SignalR

SignalR for Xamarin doesn't have way to work through Websockets.
I have a web service with messaging by SygnalR by websockets.
Can i receive message in Xamarin without implementing SignalR to Xamarin?
Is it important to have SignalR on Xamarin client side?
If you have implemented a SignalR hub in your sever, you can use SignalR Client nuget in Xamarin. The transport will be SSE (Server Sent Events) by default, but it works pretty well.
Implementing a websocket in the client just to connect to a SignalR server makes no sense at all, unless you really need to use WebSockets instead of SSE.
SignalR uses transports to connect to the server. The portable version of SignalR client does not support the webSockets transport since there is no portable version of WebSocket client available. This is fine since there are two more transports - longPolling and serverSentEvents that can be used to talk to the server.
You can't connect to the SignalR 2.x server with bare webSockets. There is a protocol that needs to be followed and if a client does not follow this protocol its requests will be rejected.
If you absolutely need to use websockets you can implement your own websockets transport by implementing the IClientTransport interface and pass it to the Start method. This is how the webSockets transport is supported on UWP. Here is all the code I needed to write.

Connect to WebSocket server on Asp.Net Core

How to establish connection and send messages to remote WebSocket server from ASP.NET Core?
Is it possible now or I should wait for SignalR library to achieve this?
Sounds like you're looking for System.Net.WebSockets.Client. It's available, but not on all platforms (https://github.com/dotnet/corefx/issues/2486).

Can SignalR be used to update clients which are servers by itself?

I'm trying to implement a Server which is a Asp.Net WebApi. This server is accessed by so many child services(let it be web servers). Can SignalR be used to update these child servers so that the child servers can update all the clients attached to them?
SignalR is a Server <> Client technology, it can be used Server <> Server but its better to use a Service bus like nServicebus or MQ to pub / sub between services.
edit: If its for scalability only you can use SignalR scaleout features

Resources