SignalR如何重复连接Id处理? [英] SignalR How is a duplicate Connection Id handled?

查看:1732
本文介绍了SignalR如何重复连接Id处理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了自己的 IConnectionIdGenerator 实现,它在我的WebForms simpicty应用程序名称的登录身份验证的用户客户端连接ID的EmailAddress.ToLower()(如果这不是可用,则默认返回一个GUID)。
从调用我的网页code客户端背后的一切工作正常。

I have created my own IConnectionIdGenerator implementation which for simpicty in my webforms application names the client connection Id by the EmailAddress.ToLower() of the logged in authenticated user (if that’s not available then it defaults back a guid). Calling the client from my page code behind all works fine.

hubContext.Clients[LoggedInUser.EmailAddress.ToLower()].updateProgress(i)

不过看来,如果我打开另一个浏览器或标签与登录用户相同的两个在Windows的foreverframe连接不断给一个301的结果,那么200结果交替和重复。

However it seems that if I open another browser or tab with the same logged in user both the foreverframe connection on both windows keeps giving a 301 result then a 200 result alternating and repeating.

我认为分配相同的连接ID只给我一个简单的方法,以确保正确的信息去系统的正确的用户,无论他们在哪里连接

I assumed that assigning the same connection Id would just give me an easy way to make sure messages correctly go to the correct user of the system no matter where they connected.

他们总是必须是唯一的,我将要兴建另一个层来管理连接登录的用户帐户还是我这里缺少一个窍门?

Do they always have to be unique and will I have to build another layer to manage connections to logged-in user accounts or am I missing a trick here?

推荐答案

连接ID必须是唯一的。如果你没有让他们独特的那么一会其他连接线下踢。在内部,我们使用的连接ID为连接的唯一标识符,我们断开易受骗的人。

Connection ids have to be unique. If you don't make them unique then one will kick the other connection offline. Internally we use the connection id as a unique identifier for a connection and we disconnect dupes.

如果你得到重复301的反应很可能是因为你有你的应用程序称为signalr一个文件夹,它是没有直接关系的共享连接ID。

If you get repeated 301 responses it's likely because you have a folder in your app called signalr, and it isn't directly related to sharing connection ids.

这篇关于SignalR如何重复连接Id处理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆