ran fine on localhost, no response after being deloyed

47 views
Skip to first unread message

Liang Qiao

unread,
Jun 30, 2012, 7:26:23 AM6/30/12
to no...@googlegroups.com
Hi all,



I develop a chat server for a titanium app and it ran fine on localhost. But after deploying to server(I tried both nodejitsu and heroku), " now = nowjs.nowInitialize()" would get undefined. 

I init nowjs from local files.
var nowjs = require('../../lib/nodeclient/now.js');

I am running the most up-to-date socket.io.

Any suggestion would be greatly appreciated.

Thank you


Liang Qiao

unread,
Jun 30, 2012, 7:31:06 AM6/30/12
to no...@googlegroups.com
actually I tried to deploy https://github.com/Flotype/now/tree/master/lib/nodeclient on nodejitsu or heroku, but failed

Ian Serlin

unread,
Jul 1, 2012, 5:16:38 PM7/1/12
to no...@googlegroups.com
Hi Liang,

I think Heroku doesn't open the ports necessary for websockets. This line: var nowjs = require('../../lib/nodeclient/now.js'); will only work on the server-side while now = nowjs.nowInitialize() is typically used on the client. Are you developing a server-to-server application? Also if you could post some of your code on pastie.org or something similar that would help me get a better idea of what you're trying to do.

Thanks!

Liang Qiao

unread,
Jul 1, 2012, 8:44:59 PM7/1/12
to no...@googlegroups.com
Hi Ian,

Thanks for the reply. I really appreciate it!

I am developing a Titanium mobile app, which I think is running js from a native phone environment. So it is a mobile-to-server application and I am following this 


, which works fine when I run node my machine but failed to connect remote node server.

I can establish the connection by now.initialise() from phone,  now = nowjs.nowInitialize('//127.0.0.1:8080',{}); but it will fail connecting to a real server.

eg. if I change 127.0.0.1 to http://strong-stream-4567.herokuapp.com/ now.initialise() would fail.

But the weird thing is I am also serving a webpage running nowjs, which you can try http://strong-stream-4567.herokuapp.com/ ,  for testing,  and that part always works. But I just cannot connect from phone. I also tried nodejitsu and AWS and the same thing happened. Webpage works but not the mobile client, which only works with localhost. But for AWS, I can connect the server using var nowjs = require('../../lib/nodeclient/now.js');

I am wondering what has changed from localhost to a real server..



Regards,

Qiao Liang

Ian Serlin

unread,
Jul 6, 2012, 1:35:58 PM7/6/12
to no...@googlegroups.com
I'm not sure if you've figured this one out or not yet, but when writing mobile applications (caveat: I've never used Titanium, mostly Sencha Touch) I've had to explicitly enable network access and provide a whitelist of urls the application is allowed to contact, or at least the wildcard '*' for allowing contact to everything. Perhaps Titanium has a setting related to this?

Hope that helps!
Reply all
Reply to author
Forward
0 new messages