Mongo Db ReplicaSet connection String

We have an API running on Mongo 4.0, Yii 2.0.15 and yii2-mongodb (2.1.7). We have connection string defined as
return [
‘components’ => [

    'mongodb' => [
        'class' => '\yii\mongodb\Connection',
        'dsn' =>  'mongodb://mongo07:27017,mongo08:27017,mongo09:27017/?replicaSet=p&connectTimeoutMS=480000&socketTimeoutMS=520000&readPreference=secondary',
        'defaultDatabaseName' => 'panelmanagement',
    ],
    
    ],
  ];

When we are trying to make API calls we are getting an error like

“name”: “MongoDB Exception”,
“message”: “not master”,
“code”: 10107,
“type”: “yii\mongodb\Exception”,
“file”: “/home/ubuntu/XXX/vendor/yiisoft/yii2-mongodb/src/Command.php”,
“line”: 192,
“stack-trace”: [

Please let us know if you see any issues or is there any other way to connect to Replicasets in yii2-mongodb (2.1.7)