mongodb / laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel (Moloquent)

Home Page:https://www.mongodb.com/compatibility/mongodb-laravel-integration

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fetching data via tinker

ivankrister opened this issue · comments

  • Laravel-mongodb Version: 4.1.0
  • PHP Version: 8.2.12
  • Database Driver & Version: Atlas Mongo DB Serverless V2 Version 7.1.1

Description:

Steps to reproduce

  1. Install mongo db version 4.1.0 in laravel 10.37.3
  2. Set up using DB_DSN
  3. Fetch any data using model in tinker

Expected behaviour

Display the collection on the specific model that call

Actual behaviour

Error
MongoDB\Driver\Exception\InvalidArgumentException Failed to parse URI options: Failed to look up SRV record "_mongodb._tcp.XXXX.XXX.mongodb.net": A temporary error occurred on an authoritative name server. Try again later.

BUT everything fine when calling in routes

Hi @ivankrister, does the error persist or does it eventually go away? By default, MongoDB Atlas uses the mongodb+srv protocol in its connection string, which instructs the driver to do a DNS lookup on the given hostname to get the initial list of servers to connect to. The error you're encountering is an error reported by your operating system. Did you confirm that the same connection string was used in tinker and the web application where it works?

Yes, @alcaeus i confirm that im using same connection in my web and tinker im using mongodb+srv protocol in my connection and i call config('database.connections.mongodb') in my tinker and web it gives similar result, but error still exists in tinker when fetching data