webman push windows下能收到ping/pong,但收不到推送消息

keroppi

问题描述

这里详细描述问题
windows 用命令行启动 php windows.php 客户端能连接、正常处理ping/pong ,但收不到服务端推送的消息

程序代码

服务器

use Webman\Push\Api as PushApi;

try {
$pushApi = new PushApi(
    config('plugin.webman.push.app.api'),
    config('plugin.webman.push.app.app_key'),
    config('plugin.webman.push.app.app_secret')
);
} catch (PushException $e) {
    echo $e->getMessage();

    return 'initial error';
}

for ($i = 0; $i < 20; $i++) {

    $msg = "test message {$i}";
    echo $msg."\n";
    $pushApi->trigger("user-game", "message", [
        'from_uid' => 2,
        'content'  => "你好,这个是消息内容: {$i}"
    ]);
}

前端代码

<script>
    window.onload = function(){

        var connection = new Push({
            url: 'ws://127.0.0.1:3131', // websocket地址
            app_key: 'aaa271c93a460f6212870a93c4133b27',
            auth: '/plugin/webman/push/auth' // 订阅鉴权
        });

        // 浏览器监听 game 频道消息
        var game_channel = connection.subscribe('user-game');

        game_channel.on('message', function(data) {
            // data里是消息内容
            console.log(data);
        });
    }
</script>    

报错信息

前端控制台查看 websocket 相应信息

{"event":"pusher:connection_established","data":"{\"socket_id\":\"1.4\",\"activity_timeout\":55}"}  98  
17:12:14.662
{"event":"pusher:subscribe","data":{"channel":"user-game"}} 59  
17:12:14.663
{"event":"pusher_internal:subscription_succeeded","data":"{}","channel":"user-game"}    84  
17:12:14.663
{"event":"pusher:ping","data":{}}   33  
17:12:40.633
{"event":"pusher:pong","data":"{}"} 35  
17:12:40.633
{"event":"pusher:ping","data":{}}   33  
17:13:06.631
{"event":"pusher:pong","data":"{}"} 35  
17:13:06.632
{"event":"pusher:ping","data":{}}   33  
17:13:32.625
{"event":"pusher:pong","data":"{}"}

操作系统及workerman/webman等框架组件具体版本

"workerman/webman-framework": "~2.1",
"webman/push": "^1.1"

90 0 1
0个回答

×
🔝