更新时间:2022-05-14 08:47:51
A connect failed: ECONNREFUSED (Connection denied)
很可能意味着在该端口和该 IP 地址上没有侦听任何内容.可能的解释包括:
A connect failed: ECONNREFUSED (Connection refused)
most likely means that there is nothing listening on that port AND that IP address. Possible explanations include:
请注意,虽然您有一个名为 urls
的数组变量,但它不能包含真正的 URL.Socket
构造函数没有任何形式的真正 URL 的重载.事实上,如果你提供了一个像这样的字符串形式的 URL:
Note that while you have an array variable called urls
, it cannot contain real URLs. There is no overload of the Socket
constructor that takes a real URL in any form. Indeed, if you supplied a URL in string form like this:
new Socket("http://example.com", 42)
结果将是一个不同的例外.同样,如果您尝试连接到无法路由到的网络上的 IP 地址(例如不同的 WiFi 网络"),那么您将收到不同的异常;例如找不到主机"、没有到主机的路由"或没有到网络的路由".
the result would be a different exception. Likewise, if you attempt to connect to an IP address on a network that you can't route to (e.g. "a different WiFi network"), then you will get a different exception; e.g. "host not found", "no route to host" or "no route to network".