大佬们本地webman搞下来之后websocket控制台连接测试失败,http也起不来了 ,重新来更新了,已经解决了,结果在最后

有时有晌

问题描述

大佬们本地webman搞下来之后websocket控制台连接测试失败, 尝试了各种姿势 结果就是一个字 fail

程序代码

class Websocket
{
    public function onConnect(TcpConnection $connection){}

    public function onWebSocketConnect(TcpConnection $connection, $http_buffer){}

    public function onMessage(TcpConnection $connection, $data)
    {
        $data = json_decode($data, true);

//        Timer::add(1, function() use ($return_ret, $connection, $data){
//            // >>>>>>>>>>>>>>>>>>>>>>>
//            // 处理代码业务
//            // >>>>>>>>>>>>>>>>>>>>>>>
//
//            // 发送数据  $return_ret 推送的数据
//            $connection->send(json_encode($return_ret));
//        });

        $data=["code"=>0,'data'=>[1,2,3,4],'msg'=>'success'];
        $connection->send(json_encode($data));
    }

    public function onClose(TcpConnection $connection)
    {
        // 关闭websocket
        $connection->close();
    }
}

报错信息

http 打不开 websocket 也连不上 难道是我姿势不对吗



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

window

下面是 composer.json 文件
{
  "name": "workerman/webman",
  "type": "project",
  "keywords": [
    "high performance",
    "http service"
  ],
  "homepage": "https://www.workerman.net",
  "license": "MIT",
  "description": "High performance HTTP Service Framework.",
  "authors": [
    {
      "name": "walkor",
      "email": "walkor@workerman.net",
      "homepage": "https://www.workerman.net",
      "role": "Developer"
    }
  ],
  "support": {
    "email": "walkor@workerman.net",
    "issues": "https://github.com/walkor/webman/issues",
    "forum": "https://wenda.workerman.net/",
    "wiki": "https://workerman.net/doc/webman",
    "source": "https://github.com/walkor/webman"
  },
  "require": {
    "php": ">=7.2",
    "workerman/webman-framework": "^1.5.0",
    "monolog/monolog": "^2.0",
    "webman/gateway-worker": "^1.0"
  },
  "suggest": {
    "ext-event": "For better performance. "
  },
  "autoload": {
    "psr-4": {
      "": "./",
      "app\\": "./app",
      "App\\": "./app",
      "app\\View\\Components\\": "./app/view/components"
    },
    "files": [
      "./support/helpers.php"
    ]
  },
  "scripts": {
    "post-package-install": [
      "support\\Plugin::install"
    ],
    "post-package-update": [
      "support\\Plugin::install"
    ],
    "pre-package-uninstall": [
      "support\\Plugin::uninstall"
    ]
  }
}

成功了

339 3 1
3个回答

roczyl
nitron

看着有点无奈

  • 有时有晌 2023-07-13

    没玩过,过来玩一下,之前0.0.0.0进去非常丝滑,突然不行了。

稚出

牛。。。。。

🔝