Search code examples
javascriptandroidnode.jshttpserverappfog

Two node.js servers?


I want to run two node.js httpservers on different ports:

var http = require('http');        

var dbserver = http.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'text/html'});
    res.write('<html><body><h2 align=center>TEST index.html.</h2></body></html>');
    res.end();
});

dbserver.listen(8888);

var s = http.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.write('hello world');
    res.end();
});

s.listen(8080);

I want to make android application that will connect to my Node.js server on port 8888 on AppFog hosting, send a message to the server, and receive a response from it. And if i open my server from browser i get just a simple html page. But my code doesn't works. Why?


Solution

  • Well, well, well, I've had an e-mail answer from AppFog support it sounds like this:

    //----------------------------------------------------------------------

    Joe, Sep 19 12:30 (PDT):

    Hi!

    Unfortunately, only HTTP traffic is supported on AppFog, so websockets and UDP traffic won't work. Websocket support is on our roadmap, though, so please stay tuned!

    Joe AppFog Support

    //---------------------------------------------------------------------

    So the problemm was not in Node.js, and not in my code, but on AppFog. Thank you all very much for your help!