Note that there are some explanatory texts on larger screens.

plurals
  1. POHosting a nodejs server on dotcloud
    primarykey
    data
    text
    <p>I am trying to host a nodejs app on the hosting service "dotcloud". My nodejs uses the package "websocket" to handle communications. ie. npm install websocket</p> <p>My app works great when it's running on localhost on my laptop. But when I deploy the app on dotcloud it does not work correctly.</p> <p>Here is what is going on: You point your browser to the url on dotcloud: pirate-captainlonate.dotcloud.com</p> <p>Then, express handles the GET request with express.get('/'.......){} express serves the .html page to the client as you would expect. The .html file in turn tries to establish the websocket connection with the server. Again I can get this to work just fine on my local machine. However, no connection is being established. Specifically, the dotcloud is definitely serving me the .html file, but the .html file is not establishing the websocket connection with the server. But connection.onerror isn't being called either. It's weird. </p> <p>Here is some code to help you understand what I'm doing:</p> <p><strong>Client Side:</strong></p> <pre><code>this.connection = new WebSocket('ws://pirate-captainlonate.dotcloud.com:1337'); this.connection.onerror = function (error) { console.log("ERROR with the connection *sadface*"); }; **** Note that I note the onerror function here to show that I do indeed have it set up, but it's not being called. It would seem that no error is being thrown. </code></pre> <p><strong>Server Side:</strong></p> <pre><code>var webSocketServer = require('websocket').server; // websocket var server = require('http').createServer(); var expr = require("express"); // load the express module var xpress = expr(); // xpress now holds the server object // Helps Node serve the game.html page upon a get request xpress.configure(function() { xpress.use(expr.static(__dirname + "/public")); xpress.set("view options", {layout: false}); }); // All requests to root serve the game.html page xpress.get('/', function(req, res) { res.sendfile(__dirname + '/public/game.html'); }); // What ports to listen on var webSocketsServerPort = 1337; xpress.listen(8080); server.listen(webSocketsServerPort, function() { console.log((new Date()) + " Server is listening on port " + webSocketsServerPort); }); // WebSocket Server var wsServer = new webSocketServer({ httpServer: server }); </code></pre> <p>That should be enough code to show you guys how it's working. Now one of you will probably ask, what is ">> dotcloud logs" showing?</p> <pre><code>[www.0] ==&gt; /var/log/supervisor/app.log &lt;== [www.0] Sat Feb 16 2013 02:57:59 GMT+0000 (UTC) Server is listening on port 1337 [www.0] ==&gt; /var/log/supervisor/supervisord.log &lt;== [www.0] 2013-02-16 02:57:57,946 WARN Included extra file "/home/dotcloud/current/supervisord.conf" during parsing [www.0] 2013-02-16 02:57:58,033 INFO RPC interface 'supervisor' initialized [www.0] 2013-02-16 02:57:58,033 WARN cElementTree not installed, using slower XML parser for XML-RPC [www.0] 2013-02-16 02:57:58,033 CRIT Server 'unix_http_server' running without any HTTP authentication checking [www.0] 2013-02-16 02:57:58,038 INFO daemonizing the supervisord process [www.0] 2013-02-16 02:57:58,039 INFO supervisord started with pid 140 [www.0] 2013-02-16 02:57:59,048 INFO spawned: 'app' with pid 154 [www.0] 2013-02-16 02:58:00,290 INFO success: app entered RUNNING state, process has stayed up for &gt; than 1 seconds (startsecs) [db.0] ==&gt; /var/log/mongodb/mongodb.log &lt;== [db.0] Sat Feb 16 01:45:02 [conn4] end connection 127.0.0.1:51326 (0 connections now open) </code></pre> <p>Alright, well I'd really like to get this working. I've been at this forever. Let me know if there is anything else you guys need to help me answer my question.</p> <p>Thanks,</p> <p>--Nathan</p> <p><em>Addendum: This is how server is sending the html file.</em></p> <pre><code>xpress.get('/', function(req, res) { res.sendfile(__dirname + '/public/game.html'); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload