简体   繁体   English

在Socket.IO中限制每台计算机/用户的连接套接字

[英]Limit connected socket per computer/user in Socket.IO

How can I limit the number of connected socket per computer/user to Socket.IO server? 如何将每台计算机/用户连接的套接字数量限制为Socket.IO服务器?

I know I can use session, but if the user tries to use multiple web browser then that would be useless. 我知道我可以使用会话,但如果用户尝试使用多个Web浏览器,那么这将是无用的。
IP address could also be used in this case, but if I use IP address then it would prevent other users behind the same router (same IP address) to connect to the server 在这种情况下也可以使用IP地址,但是如果我使用IP地址,那么它将阻止同一路由器(相同IP地址)后面的其他用户连接到服务器

Any other suggestion? 还有其他建议吗?

You can only limit connections by: 您只能通过以下方式限制连接:

a) IP, which you said you don't want a)IP,你说你不想要的
b) Browser, since you can remember cookies (but if somebody opens multiple 'incognito' tabs with Chrome for example it can bypass this; also if they open another browser they can bypass this) b)浏览器,因为您可以记住cookie(但是,例如,如果有人使用Chrome打开多个“隐身”标签,则可以绕过此操作;如果他们打开另一个浏览器,也可以绕过此操作)

You cannot determine if a user is behind a router. 您无法确定用户是否在路由器后面。

My suggestion: 我的建议:

Limit by both ip and browser: set a maximum number of connections for an ip and allow only one connection for the same browser. 通过ip和浏览器限制:为ip设置最大连接数,并且只允许同一浏览器使用一个连接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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