Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetching data via tinker #2697

Open
ivankrister opened this issue Dec 19, 2023 · 4 comments
Open

Fetching data via tinker #2697

ivankrister opened this issue Dec 19, 2023 · 4 comments

Comments

@ivankrister
Copy link

ivankrister commented Dec 19, 2023

  • 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

@alcaeus
Copy link
Member

alcaeus commented Dec 19, 2023

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?

@ivankrister
Copy link
Author

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

@lokesh-zersys
Copy link

For me its the other way around, From tinker It works, but calling from routes it throws the below error.

No suitable servers found (serverSelectionTryOnce set): [connection error calling hello on 'xxxxx.docdb.amazonaws.com:27017'] {"userId":11,"exception":"[object] (MongoDB\Driver\Exception\ConnectionTimeoutException(code: 13053): No suitable servers found (serverSelectionTryOnce set): [connection error calling hello on 'xxxxx.docdb.amazonaws.com:27017'] at /home/forge/default/vendor/mongodb/mongodb/src/functions.php:520)

@ivankrister is the issue fixed?

@alcaeus
Copy link
Member

alcaeus commented Mar 12, 2024

@lokesh-zersys the error you are receiving is likely unrelated and has a very different root cause.

I've also noted that you're using DocumentDB, so please contact AWS support for any issues you encounter as it's not supported by the MongoDB driver. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants