Home >Backend Development >Golang >I can't have more than 28233 websocket connections on my localhost (for stress testing) | Go client (gorilla)

I can't have more than 28233 websocket connections on my localhost (for stress testing) | Go client (gorilla)

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBforward
2024-02-06 09:15:08845browse

我的本地主机上的 websocket 连接数不能超过 28233 个(用于压力测试)| Go 客户端(大猩猩)

Question content

I am trying to create a pool of clients connected to the same websocket server (go server) to test performance and handle incoming requests Ability.

For example, I was wondering how I could reach 100k clients because I saw that when I reached 28233 gorilla clients (websocket clients), the program couldn't create more.

I get the following error

tcp 127.0.0.1:8000: connect: cannot assign requested address

Thanks in advance


Correct answer


There cannot be 100k concurrent client connections from 127.0.0.1 to 127.0.0.1:8000. Each of these parallel client connections must have a different source port (otherwise it's not a different connection), and only 64k source ports are available. In practice, the number is even less, as the system will start from ephemeral ports or even less (depending on the operating system and configuration).

If the system cannot select a unique source port that is not in use by another connection to the same destination IP and port, then you will receive "Unable to assign requested address."

If you want to support more parallel connections, you need to change other parameters of the connection, not just the source port. Typically this is done by not using a single server socket but multiple sockets listening on different ports.

The above is the detailed content of I can't have more than 28233 websocket connections on my localhost (for stress testing) | Go client (gorilla). For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:stackoverflow.com. If there is any infringement, please contact admin@php.cn delete