I'm using SignalR 1.0.4 and have a hub that returns a ChannelReader created from an observable by an extension.
A typescript client (also 1.0.4) is forced to connect using websockets only, and streams data from this channel fine.
Now I'm testing scale out using 2 instances of the hub, both using the same Redis connection. I'm emitting values from the channel's observable on both instances but the client only appears to be receiving data from the instance it is connected to. My conclusion is that the channel reader data is not broadcast to other channels via Redis.
I've tried to replicate this using the SignalRSamples by replicating the project and giving the copy different host IPs to emulate 2 load-balanced instances. I add the same Redis connection to both projects and start both up.
Regular websocket connections via the hubs.html have no problem broadcasting data across instances. The streaming.html doesn't replicate data for observable or channel reader.
Are channel readers meant to be used in this way, i.e. can they scale out?
ChannelReaders are meant to stream data down to the caller of the method. They don't participate in scale-out at all. Consider them the same as standard return values, SignalR just supports enumerating items off them over time. The programming model is very similar to how iterators work in C# (methods that use the yield
keyword). If you want to broadcast messages to other clients, you should just use the Clients
property on the Hub
base class and send messages to those clients.