Code Monkey home page Code Monkey logo

Comments (6)

nodkz avatar nodkz commented on August 31, 2024 1

It's very strange. By provided debug output all looks legit. mongodb-memory-server works as expected. The problem somewhere in your test file or machine.
Can you provide your test case?

PS. Also try to change obtained host in uri:

let uri = await mongod.getConnectionString();
uri = uri.replace('localhost', '127.0.0.1'); // maybe some problems with resolving `localhost` on you machine, eg. it points on ipv6 or other ip address than 127.0.0.1

PSS. Maybe helps some timeout before connection:

const uri = await mongod.getConnectionString();
await new Promise(resolve => { setTimeout(resolve, 5000); }); // lets wait 5 second before connection to MongoDB

Firstly we need to resolve the error and obtain a working solution. After that we can optimize it, put fix to the code or add some note to README.md.

from mongodb-memory-server.

nodkz avatar nodkz commented on August 31, 2024

Please use debug: true option and post here your output.

from mongodb-memory-server.

rommguy avatar rommguy commented on August 31, 2024
Mongo[53357] Starting MongoDB instance with following options: {"port":53357,"dbName":"c7f67e84-beb8-4c69-8c5c-d6f884924534","uri":"mongodb://localhost:53357/c7f67e84-beb8-4c69-8c5c-d6f884924534","storageEngine":"ephemeralForTest","dbPath":"/var/folders/81/v_z30jtn7rx1l6jwphrbr5000000gn/T/mongo-mem-449442g7byUjJf2dF"} +0ms
  Mongo[53357] MongoBinary: Mongod binary path: /Users/guyromm/.mongodb-binaries/latest/mongod +2ms
  Mongo[53357] MongoBinary: Download lock removed +6ms
  Mongo[53357] 2018-08-27T06:44:24.285+0300 I CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
  Mongo[53357]  +26ms
  Mongo[53357] 2018-08-27T06:44:24.297+0300 I CONTROL  [initandlisten] MongoDB starting : pid=44945 port=53357 dbpath=/var/folders/81/v_z30jtn7rx1l6jwphrbr5000000gn/T/mongo-mem-449442g7byUjJf2dF 64-bit host=Guys-MacBook-Pro.local
  Mongo[53357] 2018-08-27T06:44:24.297+0300 I CONTROL  [initandlisten] db version v3.7.9-154-g51dce76
  Mongo[53357]  +11ms
  Mongo[53357] 2018-08-27T06:44:24.297+0300 I CONTROL  [initandlisten] git version: 51dce76324173089098e8c9fd09e46b98b32adc4
  Mongo[53357] 2018-08-27T06:44:24.297+0300 I CONTROL  [initandlisten] allocator: system
  Mongo[53357] 2018-08-27T06:44:24.297+0300 I CONTROL  [initandlisten] modules: none
  Mongo[53357] 2018-08-27T06:44:24.297+0300 I CONTROL  [initandlisten] build environment:
  Mongo[53357] 2018-08-27T06:44:24.297+0300 I CONTROL  [initandlisten]     distarch: x86_64
  Mongo[53357] 2018-08-27T06:44:24.297+0300 I CONTROL  [initandlisten]     target_arch: x86_64
  Mongo[53357] 2018-08-27T06:44:24.297+0300 I CONTROL  [initandlisten] options: { net: { port: 53357 }, security: { authorization: "disabled" }, storage: { dbPath: "/var/folders/81/v_z30jtn7rx1l6jwphrbr5000000gn/T/mongo-mem-449442g7byUjJf2dF", engine: "ephemeralForTest" } }
  Mongo[53357]  +0ms
  Mongo[53357] 2018-08-27T06:44:24.303+0300 I CONTROL  [initandlisten] 
  Mongo[53357] 2018-08-27T06:44:24.303+0300 I CONTROL  [initandlisten] ** NOTE: This is a development version (3.7.9-154-g51dce76) of MongoDB.
  Mongo[53357] 2018-08-27T06:44:24.303+0300 I CONTROL  [initandlisten] **       Not recommended for production.
  Mongo[53357] 2018-08-27T06:44:24.303+0300 I CONTROL  [initandlisten] 
  Mongo[53357] 2018-08-27T06:44:24.303+0300 I CONTROL  [initandlisten] ** WARNING: This server is bound to localhost.
  Mongo[53357]  +6ms
  Mongo[53357] 2018-08-27T06:44:24.303+0300 I CONTROL  [initandlisten] **          Remote systems will be unable to connect to this server. 
  Mongo[53357] 2018-08-27T06:44:24.303+0300 I CONTROL  [initandlisten] **          Start the server with --bind_ip <address> to specify which IP 
  Mongo[53357] 2018-08-27T06:44:24.303+0300 I CONTROL  [initandlisten] **          addresses it should serve responses from, or with --bind_ip_all to
  Mongo[53357] 2018-08-27T06:44:24.303+0300 I CONTROL  [initandlisten] **          bind to all interfaces. If this behavior is desired, start the
  Mongo[53357] 2018-08-27T06:44:24.303+0300 I CONTROL  [initandlisten] **          server with --bind_ip 127.0.0.1 to disable this warning.
  Mongo[53357] 2018-08-27T06:44:24.303+0300 I CONTROL  [initandlisten] 
  Mongo[53357] 2018-08-27T06:44:24.303+0300 I CONTROL  [initandlisten] 
  Mongo[53357] 2018-08-27T06:44:24.303+0300 I CONTROL  [initandlisten] ** NOTE: The ephemeralForTest storage engine is for testing only. 
  Mongo[53357] 2018-08-27T06:44:24.303+0300 I CONTROL  [initandlisten] **       Do not use in production.
  Mongo[53357]  +0ms
  Mongo[53357] 2018-08-27T06:44:24.303+0300 I CONTROL  [initandlisten] 
  Mongo[53357]  +1ms
  Mongo[53357] 2018-08-27T06:44:24.308+0300 I STORAGE  [initandlisten] createCollection: admin.system.version with provided UUID: 32c711d6-c0c5-44bd-8f0f-539902c3b457
  Mongo[53357]  +4ms
  Mongo[53357] 2018-08-27T06:44:24.308+0300 I COMMAND  [initandlisten] setting featureCompatibilityVersion to 4.0
  Mongo[53357]  +1ms
  Mongo[53357] 2018-08-27T06:44:24.309+0300 I STORAGE  [initandlisten] createCollection: local.startup_log with generated UUID: 505eae10-04c7-42c6-9e38-6b8038c037b8
  Mongo[53357]  +0ms
  Mongo[53357] 2018-08-27T06:44:24.309+0300 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/var/folders/81/v_z30jtn7rx1l6jwphrbr5000000gn/T/mongo-mem-449442g7byUjJf2dF/diagnostic.data'
  Mongo[53357]  +0ms
  Mongo[53357] 2018-08-27T06:44:24.311+0300 I NETWORK  [initandlisten] waiting for connections on port 53357
  Mongo[53357]  +2ms
  Mongo[53357] MongodbInstance: is ready! +0ms

Than this error on connect
failed to connect to server [localhost:53357] on first connect [MongoNetworkError: getaddrinfo ENOTFOUND localhost localhost:53357]

from mongodb-memory-server.

nodkz avatar nodkz commented on August 31, 2024

BTW what OS do you using?

from mongodb-memory-server.

rommguy avatar rommguy commented on August 31, 2024

Thank you very much.
This fixed it - uri = uri.replace('localhost', '127.0.0.1')

I'm, using OSX

from mongodb-memory-server.

nodkz avatar nodkz commented on August 31, 2024

Thanks for the feedback. For a new package version, this problem will be fixed.

from mongodb-memory-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.