MongoConnectionException:找不到合适的服务器

时间:2019-07-12 16:10:26

标签: mongodb symfony fosuserbundle fosoauthserverbundle

我正在尝试使用FOSUserBundle和FOSOauthServerBundle以及DoctrineMongoDBBundle来实现基于其余API令牌的身份验证, 当调用需要身份验证的路由时,我设置了配置并使用“ doctrine:mongodb:schema:create”和“ fos:user:create”创建了架构和用户,我在日志中遇到以下错误:

request.CRITICAL: Uncaught PHP Exception MongoConnectionException: "No suitable servers found (`serverSelectionTryOnce` set): [connection refused calling ismaster on 'localhost:27017']" at /var/www/html/middleware/vendor/alcaeus/mongo-php-adapter/lib/Alcaeus/MongoDbAdapter/ExceptionConverter.php line 79 {"exception":"[object] (MongoConnectionException(code: 13053): No suitable servers found (`serverSelectionTryOnce` set): [connection refused calling ismaster on 'localhost:27017'] at /var/www/html/middleware/vendor/alcaeus/mongo-php-adapter/lib/Alcaeus/MongoDbAdapter/ExceptionConverter.php:79, MongoDB\\Driver\\Exception\\ConnectionTimeoutException(code: 13053): No suitable servers found (`serverSelectionTryOnce` set): [connection refused calling ismaster on 'localhost:27017'] at /var/www/html/middleware/vendor/mongodb/mongodb/src/Collection.php:612)"} []

这是我的配置:

doctrine_mongodb:
    connections:
        default:
            server: "%mongodb_server%"
            options: { username: "%mongodb_username%", password: "%mongodb_password%" }
    default_database: "%mongodb_database%"
    document_managers:
        default:
            auto_mapping: true

fos_user:
    db_driver: mongodb
    firewall_name: api                                        
    user_class: AppBundle\Document\User
    from_email:
        address: "%mailer_user%"
        sender_name: "%mailer_user%"

 fos_oauth_server:
    db_driver:           mongodb
    client_class:        AppBundle\Document\Client
    access_token_class:  AppBundle\Document\AccessToken
    refresh_token_class: AppBundle\Document\RefreshToken
    auth_code_class:     AppBundle\Document\AuthCode
    service:
        user_provider: fos_user.user_provider.username

使用:

parameters:
    secret: ThisTokenIsNotSoSecretChangeIt
    mongodb_server: mongodb://mongodb_forms:27017
    mongodb_database: pocforms
    mongodb_username: forms
    mongodb_password: forms
    mailer_user: admin@forms

我发现奇怪的是,在日志中,该连接正尝试到达localhost:27017上的服务器,并且没有任何配置。

0 个答案:

没有答案