SitePoint Sponsor

User Tag List

Results 1 to 12 of 12

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Nov 2012
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Seems to hang on instance.save function...

    Hello. I'm still trying to get past the very first part of the Jump Start Node.js book where you set up the authentication form and try to connect to the mongodb database. I set up everything exactly according to the book. However when you click the "Sign Up" button it would keep timing out. So then after adding various console.log's throughout the code I was able to determine that it connects to the database just fine so that users credentials I initially set up are just fine. I was also able to determine that it appears to be hanging on the part in the User.js file where it does the instance.save function because I can get a console.log message to fire just before that line but if I put another console.log message right after that line (inside of the callback function), that console.log message does not fire ever. So it's something about that save function that is messing it up.

    I'm going through the book while at work during some down time where I'm allowed to further my javascript education so could there be something with how the network where I work is set up that is blocking the save function from working? I just figured that since I can connect to the database just fine I should be able to write to it as well but that doesn't appear to be the case at the moment.

    Anyone have any ideas for me? If not I'll just have to wait until I get home and try this all out again from there and see if things work. I've already compared all of my source code (line by line) to the source code I downloaded from the books website and besides all of the console.log statements I've put in, it is identical as far as I can tell. However, just to be safe I think I'll load up the downloaded source and of course change the database connection username and password and what not and see if the downloaded source will go through.

  2. #2
    SitePoint Member
    Join Date
    Nov 2012
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Using the downloaded source didn't make a difference. It still appears to hang right at the instance.save function call. For now I guess I'll just wait until I get home and see what happens there but if anyone has a suggestion I would appreciate it.

  3. #3
    Under Construction silver trophybronze trophy AussieJohn's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    776
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Let me know if you're having trouble getting this to work at home, that way we can at least rule out network issues.

    I don't really recall having any weird issues like that when using the book. Some other things to check are:
    - Can you console.log() inside the instance.save() callback (specifically would be worth seeing if an error is returned in the 'err' variable)
    - Does the callback you specify to the addUser function get called at all?

    It's worth noting that further on you'll install a local MongoDB instance (Beginning of Chapter 3) - if you continue to have trouble connecting/saving to MongoLab then that might be another way to keep going.
    var details = {
    . . web: "afterlight.com.au",
    . . photos: "jvdl.id.au",
    . . psa: "usethelatestversion.com"
    }

  4. #4
    SitePoint Member
    Join Date
    Nov 2012
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm still trying to get this whole thing set up on my Windows system here at home. For some reason when I go to localhost:3000/form I get the message "Cannot GET /form". What the heck does that mean? Anyone know how to set this stuff up on a Windows system?

  5. #5
    Under Construction silver trophybronze trophy AussieJohn's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    776
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    That might mean you don't have a route set up for /form or that you don't have a "form.html" in place

    You can run NodeJS fine on windows, the only part of the book that can be a little troublesome on Windows is running the tests using "make", which is a build tool traditionally installed on *nix systems. However there is a simple way to get around this by running the tests directly using Mocha. (The testing framework used in the book.) (See this post)
    var details = {
    . . web: "afterlight.com.au",
    . . photos: "jvdl.id.au",
    . . psa: "usethelatestversion.com"
    }

  6. #6
    SitePoint Member
    Join Date
    Nov 2012
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, I am using the source code downloaded from the books website. So I do have a form.html. Everything is set up like I had it on my Mac at work and I didn't have this problem at work. I don't know how I'm going to finish the book if I can't this running on either machine. Are there any other reasons it wouldn't be able to get /form?

  7. #7
    SitePoint Member
    Join Date
    Nov 2012
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nevermind. For some weird reason after I put in a console.log command it started working just fine. Also as to my first problem with the instance.save hanging on me while on my Mac at work, well it doesn't hang here at home so it's something with the network setup at work. Kind of sucks but that's the way it goes. At least I can go ahead and go through the rest of the book here at home. Thanks for all the help though AussieJohn, I appreciate it.

  8. #8
    SitePoint Author
    Join Date
    Nov 2012
    Posts
    48
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    It's probably a firewall related issue. At a guess I would say they only allow port 80 traffic whereas MongoLab use ports such as 45243. I'm glad you are enjoying the book feel free to ask more questions if you get stuck or if something is not clear

  9. #9
    SitePoint Member
    Join Date
    Mar 2014
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile

    Hi,
    Thank you all, i've just spent 8 hours on the same problem here, same situation with the book and the save thing.
    I've looked everywhere but no solution till ... here ... changed my network, hen everything worked just fine.
    I've just registered in the forum to tell you thank you all .


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •