在使用swoole开发时,
client客户端连接服务器,
出现connect to server[XXXX] failed. Error: Connection refused[111]
连接不上。
解决方法如下
1) 检查服务器对应的端口是否开启
例如
netstat -pan | grep 9502
2) 检查客户端代码
看看跟服务器是否使用同一类型连接。
例如
UDP服务器,
$serv = new swoole_server('127.0.0.1', 9502, SWOOLE_PROCESS, SWOOLE_SOCK_UDP);
在就使用UDP客户端,
$client = new swoole_client(SWOOLE_UDP);
服务器,客户端类型不一致,
也会出现Connection refused