Gateway::sendToAll()出现stream_socket_client():错误

xinaigoil
<?php
namespace app\index\controller;
require_once 'GatewayClient/Gateway.php';
// GatewayClient 3.0.0版本开始要使用命名空间
use GatewayClient\Gateway;
use think\Controller;
class Sendmsg extends Controller
{
    public function index()
    {
        // 向任意uid的网站页面发送数据
        /*Gateway::sendToClient('7f0000010b540000001f',json_encode(array(
            'type'      => 'send',
            'client_id' => 'this is ending all'
        )));//单个Client推送成功*/
        //$count = Gateway::isOnline('7f0000010b540000001d');
        Gateway::sendToAll(json_encode(array(
            'type'      => 'send',
            'client_id' => 'this is ending all'
        )));//报错stream_socket_client(): 
        //return $this->fetch();
    }
}
?>

为什么会报报错啊?

2979 6 0
6个回答

latin

要设置一个Gateway::$registerAddress的吧。

为啥不截图个具体报错?

  • 暂无评论
xinaigoil

[attach]637[/attach]
就是这个错= =?表示看不出有什么错

  • 暂无评论
latin

这个就尴尬了。
估计没有设置好Gateway::$registerAddress

  • 暂无评论
xinaigoil

那为什么单个sendToClient就能发过去呢= =
这个报错也不说的具体点,我根本就不知道怎么办了,网上搜了半天也没有

  • 暂无评论
latin

看起来是tp框架把错误给吃掉了,把代码挪出来不用tp框架估计就有具体报错了。
那个if($client){....}里的$err_msg看起来是具体的报错,但是没能有机会运行到那里

  • 暂无评论
xinaigoil

好了,解决了,还是registerAddress的问题。要跟Register里面设置的ip和端口一致,谢谢啦

  • 暂无评论
年代过于久远,无法发表回答
🔝