简体   繁体   中英

SignalR User Presence on Web Farm

I created a web chat application (asp.net mvc 5 targeted .net framework 4.0) using SignalR 1.2.0

my web chat deployed in a webfarm, i use Sql Server Back Plane to handle messaging synchronization.

the problem is on the user presence (detecting online/offline state of the user). currently i follow an example here .

in short the technique used in the example is by counting the SignalR connection. when a specific user having 1 connection the online message triggered. when user having 0 connection the offline message triggered, it also provide a timer to cleanup inactive connection which is not properly removed on the OnDisconnected event

on single server everything works fine. but when deployed on the webfarm everything seem not working expectedly. I don't understand the magic behind Microsoft.AspNet.SignalR.SqlServer but i think i miss something on that side.

any idea?

I solve it!

The problem is on the connection counting logic, number of login user can't be determine from only one server, it should be persist on the database, and calculation process can be done on each server.

in SignalR 2.1.0 OnDisconnect server event semantic changed. OnDisconnect event is fired on all nodes in a webfarm that were aware of a message. See more details about this breaking change here https://github.com/SignalR/SignalR/releases/tag/2.1.0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM