workerman作为wss客户端 接收到的消息添加数据库

Rogule

代码是这么写的:

if($arr > 1){
    $content = json_decode($arr);
    $resarr = object_to_array($content);
    foreach ($resarr as $key=>$value){
        if(isset($resarr)){
            if($resarr == "上报开门记录"){
                $socketopen = new Socketopenlog();
                $res = $socketopen->saves($resarr);
                echo $res;
                echo "已OK\n";
            }
//                    var_dump($resarr);
//                    die;
        }

    }
}else{
    echo "心跳包\n";
}

报错内容:

exception 'InvalidArgumentException' with message 'Undefined db type' in vendor/topthink/framework/library/think/Db.php:86
Stack trace:
#0 vendor/topthink/framework/library/think/Model.php(212): think\Db::connect(Array)
#1 vendor/topthink/framework/library/think/Model.php(260): think\Model->buildQuery()
#2 vendor/topthink/framework/library/think/Model.php(165): think\Model->getQuery()
#3 /webroot/boligou/socketserver.php(50): think\Model->__construct()
#4 : {closure}(Object(Workerman\Connection\AsyncTcpConnection), '481|{"seq":"477...')
#5 vendor/workerman/Connection/TcpConnection.php(658): call_user_func(Object(Closure), Object(Workerman\Connection\AsyncTcpConnection), '481|{"seq":"477...')
#6 : Workerman\Connection\TcpConnection->baseRead(Resource id #49)
#7 /webroot/boligou/vendor/workerman/Events/Select.php(294): call_user_func_array(Array, Array)
#8 /webroot/boligou/vendor/workerman/Worker.php(2323): Workerman\Events\Select->loop()
#9 /webroot/boligou/vendor/workerman/Worker.php(1454): Workerman\Worker->run()
#10 /webroot/boligou/vendor/workerman/Worker.php(1284): Workerman\Worker::forkOneWorkerForLinux(Object(Workerman\Worker))
#11 /webroot/boligou/vendor/workerman/Worker.php(1258): Workerman\Worker::forkWorkersForLinux()
#12 /webroot/boligou/vendor/workerman/Worker.php(509): Workerman\Worker::forkWorkers()
#13 /webroot/boligou/socketserver.php(130): Workerman\Worker::runAll()
#14 {main}
Worker process terminated
worker exit with status 64000

 访问的格式不正确么??

3117 1 0
1个回答

phpcreeper

with message 'Undefined db type'......这不是workerman的问题,目测是你对thinkphp的数据库的使用姿势存在问题,自己查下你的数据库数据源配置啥的。

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