swoole client出现Connection refused解决方法

在使用swoole开发时,
client客户端连接服务器,
出现connect to server[XXXX] failed. Error: Connection refused[111]
连接不上。

swoole client connect refused

解决方法如下
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

猛击这里
观看子恒老师《腾讯云短信接口开发》系列视频
了解实现过程和下载相关源代码

猜你喜欢

转载自blog.csdn.net/towtotow/article/details/81125395