confused by derby chat example http://localhost:3002

385 views
Skip to first unread message

Abigail Watson

unread,
Apr 25, 2012, 10:08:12 PM4/25/12
to der...@googlegroups.com
Hi guys!  
Got a quick question for you.  We're trying to set up a machine with Derby at the office, and have been working at getting the Chat example application running.  We seem to have everything loaded up and running...  node works, mongo works, express and all the dependencies like racer and connect-mongo are loaded.  We get it started without errors and it gives us the 'Go to: http://localhost:3002' message, but when we navigate from another machine to the server, we get nothing.  Firewalls have been checked, network interfaces are up, database is running, server.js is running.  Everything looks okay.  But we get nothing.

I've been thinking that the 'localhost' message is the culprit, and that we need to replace 'localhost' somewhere with our servers's IP address.  In the example node.js applications, the pattern is 'server.listen(3002, '192.168.0.101')' and so I've been looking for a place where the IP address is specified.  But I'm not seeing anything like that with the ExpressApp = express().use(yada, yada, yada) syntax.  And looking through the Express documentation, it looks like the IP address is taken care of automatically.

Are we missing something here?  Any suggestions on what we might be doing wrong?  Any ideas?  
Thanks in advance!
Abigail

Abigail Watson

unread,
Apr 25, 2012, 10:09:07 PM4/25/12
to der...@googlegroups.com
postscript:  oh, running on CentOS 6.2

Gregoire Welraeds

unread,
Apr 26, 2012, 6:27:43 AM4/26/12
to der...@googlegroups.com
Hi Abigail,

[no derby specific]
In normal condition, you don't have to specify an IP address to the server.listen() call. If you don't specify an IP address, the server shall bind to INADDR_ANY (0.0.0.0 IP). It means that the server shall accept connection from anywhere. If you specify an IP address, it means the server will bind to that IP and only handle connection from that IP.

Usually, you specify an IP address in the listen call when you just want to limit connections to localhost.
[/no derby specific]

By looking at the chat examples, no IP address are specified when the server is created. It probably means that derby server listen for all incoming connections, no matter the source address (even localhost), which is the default for express.js servers anyway.

 [express basic example]
var app = express.createServer();

app.get('/', function(req, res){
    res.send('Hello World');
});

app.listen(3000);       << no IP specified
[/express basic example]

I would try to run a tcpdump on the centos machine just to make sure you get the requests from the outside. My guess is that you will not.
tip: tcpdump -i eth0 'tcp port 3002'

Hope it helps
G.

Abigail Watson

unread,
Apr 26, 2012, 3:35:59 PM4/26/12
to der...@googlegroups.com
Hi Melicerte,
Thank you so much for the kind reply and clarifying how the IP address binding works.  tcpdump revealed that the server was, in fact, receiving packets.  However, when I went back to run the trace on the 'hello world' node example, I noticed that we suddenly weren't getting traffic on port 80 either; where, before, it had been working.  Long story short, iptables hadn't been permanently disabled, and when we rebooted the server, it had started up again.   All is well. We have a working chat demo.  :)

Thank you for helping take a look at the problem with fresh eyes!   
Abigail
Reply all
Reply to author
Forward
0 new messages