Titanium JIRA Archive
Appcelerator Community (AC)

[AC-1283] Cannot Change Port Number for Node.ACS Project

GitHub Issuen/a
TypeBug
Priorityn/a
StatusResolved
ResolutionWon't Fix
Resolution Date2015-09-04T05:35:34.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
LabelsTCSupportTriage, cloud, configuration-acs, node-acs, websocket
ReporterJames Sugrue
AssigneeMostafizur Rahman
Created2014-07-31T20:13:30.000+0000
Updated2016-03-08T07:37:40.000+0000

Description

Due to limitations on some 3G data networks, I need to change the port for my Node.ACS server, using websockets. This is because port 80 (the default) is blocked by some providers (see here for an example of this http://stackoverflow.com/questions/5557776/websockets-over-a-3g-connection) I tested my 3G data connection using websocketstest.com and port 8080 would work fine. I tried following the node configuration on the CLI as detailed here (http://docs.appcelerator.com/cloud/latest/#!/guide/node_cli_config). However this didn't work. I presume there must be some way to change port on a Node.ACS example?

Comments

  1. Seth Toda 2014-08-25

    Hello James, Could you just use port 443 instead? While we include socket io, we route all ports to 80 and 443. Take the following example non-mvc proxy app example:
       require('http').createServer(function(req, res){
       
       	// strip out the leading slash
       	var targetURL = String(req.url.substring(1));
       
       	// grab the host from the url
       	var externalHost = String(url.parse(targetURL).host);
       	logger.info("targetURL: "+targetURL);
       	logger.info("ExternalHost: "+externalHost);
       	req.url = "";	
       	proxy.web(req, res, {
       		target: targetURL,
       		headers: {host: externalHost}
       	},function(e){
       		//logger.info('there: '+req.url);	
       	}); 	
       }).listen(8001);
       
    Running this locally with 'acs run' will allow you to access the proxy on port 8001
     
       curl 127.0.0.1:8001/http://www.google.com
       //google webpage output
       
    But running this remotely will fail:
       curl <node endpoint>:8001/http://www.google.com
       //timeout
       
    However 80 will work:
       curl <node endpoint>:80/http://www.google.com
       
    Thank you, Seth Toda
  2. Seth Toda 2014-08-25

    This link may help explain: http://docs.appcelerator.com/cloud/latest/#!/guide/node_limitations
  3. Mauro Parra-Miranda 2014-09-05

    Hello [~jamessugrue] Did the Seth's doc help? Best Regards
  4. James Sugrue 2014-09-05

    I tried using port 443 to connect instead of 80 - that didn't work. And the limitations doc says that only one port can be used anyway. I'm deploying the app from the command line. Do you have an example of how to use an external script so that the port number can be changed? Anything I've tried there has failed. Thanks James
  5. Seth Toda 2014-09-06

    Hello James, I have not used the external script feature. 443 to https and 80 to http are blocked by your 3G data provider? What range of ports do they generally allow? Here is our link which shows how to include the startup script: http://docs.appcelerator.com/cloud/latest/#!/guide/node_config-section-scripts https://www.npmjs.org/doc/misc/npm-scripts.html
  6. James Sugrue 2014-09-06

    It seems to be a security thing on some 3G providers that port 80 is blocked for non-http calls. In my case I'm using a websocket call. No matter what I do it seems that only ws://:80 would ever connect, so I'm not running on certain 3G providers. If I use wss://:443 I can't connect from anywhere, and the same if I create a socket using ws://:443
  7. Seth Toda 2014-09-12

    Hello James, I've been doing some research on your behalf and am find that a lot of 3G providers do not play nice with web sockets. [Here](http://blog.hekkers.net/2012/12/09/websockets-and-mobile-network-operators/) is an article depicting a scenario very similar to yours. Also, can you check to see if you pass this online test via 3G? http://websocketstest.com/

JSON Source