关于-webman RPC 和 websocket

evilk

1.
webman,主要用于http服务,如果想做RPC服务,应该如何下手,文档里也没有相关资料

2.
如果想做websocket服务端,是不是只能通过自定义进程process来实现?

3.
webman,没有连接池,那是不是每个进程,都维持一个MySQL长连接呢,每个请求都复用这个MySQL长连接?

3472 4 0
4个回答

latin

https://wenda.workerman.net/question/6057 找到这个关于rpc的,看起来有用

  • 暂无评论
不败少龙

\support\bootstrap\db\Heartbeat.php

<?php
/**
 * This file is part of webman.
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the MIT-LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @author    walkor<walkor@workerman.net>
 * @copyright walkor<walkor@workerman.net>
 * @link      http://www.workerman.net/
 * @license   http://www.opensource.org/licenses/mit-license.php MIT License
 */
namespace support\bootstrap\db;

use Webman\Bootstrap;
use support\Db;

/**
 * mysql心跳。定时发送一个查询,防止mysql连接长时间不活跃被mysql服务端断开。
 * 默认不开启,如需开启请到 config/bootstrap.php中添加 support\bootstrap\db\Heartbeat::class,
 * @package support\bootstrap\db
 */
class Heartbeat implements Bootstrap
{
    /**
     * @param \Workerman\Worker $worker
     *
     * @return void
     */
    public static function start($worker)
    {
        \Workerman\Timer::add(55, function (){
            Db::select('select 1 limit 1');
        });
    }
}
  • 暂无评论
walkor

1、像@latin 说的,可以参考 https://wenda.workerman.net/question/6057
2、只能通过定义进程process来实现,webman自带一个demo
3、每个进程都维持一个mysql连接,当前进程的每个请求都复用这个连接

  • 暂无评论
xamarin

https://wenda.workerman.net/question/6460 数据库加载项从webman中独立出来,单独初始化,可以和webnan一个时间启动.在webman 路径可以随便调用数据库,不需要初始化和在composer 里做额外的工作.webman 昨天的问题已完美解决,有类似的问题欢迎兄弟们交流.谢谢兄弟们.

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