Coder Social home page Coder Social logo

Comments (4)

lazychanger avatar lazychanger commented on June 15, 2024
但是当我在server.php的settings中增加了这个配置

配置文件发一下。

我看了一下源码。有这个帧,不过WebSocket Server封装时候没有把这个帧返回给回调,你可以通过修改class_map或者其他方式,改一下看看。
image

from hyperf.

caijwei avatar caijwei commented on June 15, 2024

你的这个文件是当server是协程时才会启动,而我的项目是'mode' => SWOOLE_PROCESS,

配置文件如下
[
'mode' => SWOOLE_PROCESS,
'servers' => [
[
'name' => 'ws',
'type' => ServerInterface::SERVER_WEBSOCKET,
'host' => '0.0.0.0',
'port' => (int)env('WS_PORT'),
'sock_type' => SWOOLE_SOCK_TCP,
'callbacks' => [
Event::ON_HAND_SHAKE => [Hyperf\WebSocketServer\Server::class, 'onHandShake'],
Event::ON_MESSAGE => [Hyperf\WebSocketServer\Server::class, 'onMessage'],
Event::ON_CLOSE => [Hyperf\WebSocketServer\Server::class, 'onClose'],
],
'settings' => [
Constant::OPTION_OPEN_WEBSOCKET_CLOSE_FRAME => true,
]
]
],
'settings' => [
Constant::OPTION_ENABLE_COROUTINE => true,
Constant::OPTION_WORKER_NUM => isOnlyStartAdmin() ? 2 : (int)env('OPTION_WORKER_NUM', swoole_cpu_num()),
Constant::OPTION_PID_FILE => BASE_PATH . '/runtime/hyperf.pid',
Constant::OPTION_OPEN_TCP_NODELAY => true,
Constant::OPTION_MAX_COROUTINE => (int)env('MAX_COROUTINE', 100000),
Constant::OPTION_OPEN_HTTP2_PROTOCOL => true,
Constant::OPTION_MAX_REQUEST => (int)env('OPTION_MAX_REQUEST', 0),
Constant::OPTION_SOCKET_BUFFER_SIZE => 2 * 1024 * 1024,
Constant::OPTION_BUFFER_OUTPUT_SIZE => 2 * 1024 * 1024,
Constant::OPTION_HEARTBEAT_CHECK_INTERVAL => 2 * 60,
Constant::OPTION_HEARTBEAT_IDLE_TIME => 10 * 60,

    Constant::OPTION_DOCUMENT_ROOT => BASE_PATH . '/public',
    Constant::OPTION_ENABLE_STATIC_HANDLER => true,
    Constant::OPTION_DAEMONIZE => (int)env('OPTION_DAEMONIZE', 0),
    Constant::OPTION_OPEN_WEBSOCKET_CLOSE_FRAME => true,
],
'callbacks' => [
    Event::ON_WORKER_START => [Hyperf\Framework\Bootstrap\WorkerStartCallback::class, 'onWorkerStart'],
    Event::ON_PIPE_MESSAGE => [Hyperf\Framework\Bootstrap\PipeMessageCallback::class, 'onPipeMessage'],
    Event::ON_WORKER_EXIT => [Hyperf\Framework\Bootstrap\WorkerExitCallback::class, 'onWorkerExit'],
],

]

我在server里和顶级的settings加了这个配置,并且在启动sever时打印配置已经生效了 并通过swooleServer->set进行了配置 但是onMessage里还是拿不到关闭帧,也就拿不到code了

from hyperf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.