SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Nov 2012
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Chapter 3 - node auth 8090

    I have copied the code from page 53 as follows:

    Code JavaScript:
    var dnode = require('dnode');
    dnode(function(remote, conn) {
    	this.auth = function(user, pass, cb) {
    		var users = {
    			foo: 'bar'
    		};
    		var p = users[user];
    		if (p === pass) cb(null, 'AUTHORIZED!');
    		else cb('REMOTE ACCESS DENIED');
    	};
    }).listen(process.argv[2]);

    When I run the code as instructed node auth 8090 I get the following error

    events.js:71
    throw arguments[1]; // Unhandled 'error' event
    ^
    Error: listen EADDRINUSE
    at errnoException (net.js:769:11)
    at Server._listen2 (net.js:909:14)
    at listen (net.js:936:10)
    at Server.listen (net.js:985:5)
    at D.dnode.listen (/Users/test/node_projects/chapter03/node_modules/dnode/index.js:112:16)
    at Object.<anonymous> (/Users/test/node_projects/chapter03/dnode/auth.js:11:4)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)

    What am I doing wrong?

    >> I restarted terminal and this code is now working.
    Last edited by 2learn; Nov 25, 2012 at 12:30. Reason: Nevermind - I've got it sorted out

  2. #2
    SitePoint Author
    Join Date
    Nov 2012
    Posts
    48
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    The following error message

    Error: listen EADDRINUSE

    Means that the port is already being used. Likely the program was started somewhere else and not terminated correctly


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
  •