scotch-io / mean-machine-code

Code samples for the book: MEAN Machine
https://leanpub.com/mean-machine
MIT License
459 stars 228 forks source link

09-API mongoose trying to open closed connection #15

Closed JESii closed 9 years ago

JESii commented 9 years ago

I had been working my way through the chapter when I ran into the problem shown below which I've been unable to resolve. I tried several things (including mongoose.disconnect(), using my local mongod) which didn't work. Finally, I just cloned this repo, copied in your version of server.js and experienced the same problem. No amount of googling has provided a solution... what the heck am I doing wrong?

Thanks very much...jon

9 Feb 04:15:04 - [nodemon] starting `node server.js`
events.js:85
      throw er; // Unhandled 'error' event
            ^
Error: Trying to open unclosed connection.
    at NativeConnection.Connection.open (/Users/jseidel/dev/meanjs/mean_api/node_modules/mongoose/lib/connection.js:210:15)
    at Mongoose.connect (/Users/jseidel/dev/meanjs/mean_api/node_modules/mongoose/lib/index.js:212:15)
    at Object.<anonymous> (/Users/jseidel/dev/meanjs/mean_api/server.js:31:10)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3
9 Feb 04:15:04 - [nodemon] app crashed - waiting for file changes before starting...
justinpage commented 9 years ago

@JESii can you version-control your chapter 09 project and provide a link? I can take a look at it for you and provide feedback. I've experienced a similar issue, running npm install on root, specifically installing the mongoose module, resolved my issue.

JESii commented 9 years ago

Thank you very much! here’s the repo: https://github.com/JESii/09_mean_api https://github.com/JESii/09_mean_api

Jon Seidel, CMC® EDP Consulting, Inc. / www.edpci.com http://www.edpci.com/ / www.4mypasswords.com http://www.4mypasswords.com/ http://www.4mypasswords.com/Effective Decisions... Priceless! LinkedIn Profile http://www.linkedin.com/in/jonseidel Technology that means Business - Since 1979 phone: 510-530-6314 fax: 510-531-1522

Results that Make the Difference! The Certified Management Consultant (CMC) mark is awarded to consultants who meet the strict standards defined by the Institute of Management Consultants USA (an ISO/IEC 17024:2003 Certifying Body), including examination by their peers, client evaluations, and a written examination evidencing their understanding of the IMC USA's Code of Ethics. The CMC is the only consulting certification that has been ISO-accredited and recognized by the insurance industry as reducing risk. Check out IMC USA http://www.imcusa.org/?page=WHYHIREACMC for more information.

On Feb 9, 2015, at 3:06 PM, Justin Page notifications@github.com wrote:

@JESii https://github.com/JESii can you version-control your chapter 09 project? I can take a look at it for you and provide feedback. I've experienced a similar issue, running npm install on root, specifically installing the mongoose module, resolved my issue.

— Reply to this email directly or view it on GitHub https://github.com/scotch-io/mean-machine-code/issues/15#issuecomment-73610685.

JESii commented 9 years ago

Dang… as soon as I sent that off to you, I found the problem… user error: mongoose.connect in both server.js and app/models.user.js

thanks…jon

Jon Seidel, CMC® EDP Consulting, Inc. / www.edpci.com http://www.edpci.com/ / www.4mypasswords.com http://www.4mypasswords.com/ http://www.4mypasswords.com/Effective Decisions... Priceless! LinkedIn Profile http://www.linkedin.com/in/jonseidel Technology that means Business - Since 1979 phone: 510-530-6314 fax: 510-531-1522

Results that Make the Difference! The Certified Management Consultant (CMC) mark is awarded to consultants who meet the strict standards defined by the Institute of Management Consultants USA (an ISO/IEC 17024:2003 Certifying Body), including examination by their peers, client evaluations, and a written examination evidencing their understanding of the IMC USA's Code of Ethics. The CMC is the only consulting certification that has been ISO-accredited and recognized by the insurance industry as reducing risk. Check out IMC USA http://www.imcusa.org/?page=WHYHIREACMC for more information.

On Feb 9, 2015, at 3:06 PM, Justin Page <notifications@github.com mailto:notifications@github.com> wrote:

@JESii https://github.com/JESii can you version-control your chapter 09 project? I can take a look at it for you and provide feedback. I've experienced a similar issue, running npm install on root, specifically installing the mongoose module, resolved my issue.

— Reply to this email directly or view it on GitHub https://github.com/scotch-io/mean-machine-code/issues/15#issuecomment-73610685.