zoukankan      html  css  js  c++  java
  • No suitable servers found (`serverselectiontryonce` set): [Failed connecting to '115.28.161.44:27017': Connection timed out] php mongodb 异常

    我 php mongodb 拓展使用的是  MongoDB driver 今天查询数据的时候 偶尔会提示,

    No suitable servers found (`serverselectiontryonce` set): [Failed connecting to '115.28.161.44:27017': Connection timed out],

    提示的答题意思是 超时

    贴出我的解决方法:

            $id = I('post.id');
            $this->getassign_common_data();
            $info = D('BigdataMailCustomer')->where(['id' => $id])->find();
            $object_id = $info['object_id'];
            $coll = $info['coll'];
            $options_base = ['connectTimeoutMS' => 50000, 'socketTimeoutMS' => 50000];
            $manager = new MongoDBDriverManager(C('mongodb_auth_url'), $options_base);
            $id = new MongoDBBSONObjectId($object_id);
            $filter = ['_id' => $id];
            $options = [];
            $query = new MongoDBDriverQuery($filter, $options);
            $rows = $manager->executeQuery(C('default_db') . '.' . $coll, $query);
            $doc = [];
            foreach ($rows as $document) {
                $doc = $document;
            }
            $this->assign('d', $doc);
            $this->display('view');

    添加配置选项 连接超时 选项

  • 相关阅读:
    bootstrap多选框
    window.open()总结
    sql游标及模仿游标操作
    表变量及临时表数据批量插入和更新 写法
    表变量类型的创建及使用
    事物及exec
    [NOI2017]蚯蚓排队
    [NOI2017]游戏
    [NOI2017]蔬菜
    luogu P4194 矩阵
  • 原文地址:https://www.cnblogs.com/timelesszhuang/p/6484957.html
Copyright © 2011-2022 走看看