Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect to the process running on 'localhost' that is inside of cloud9 server

I have a Javascript project that I work on in cloud9 IDE online, and I wanted to test my code using testem npm module: npmjs.org/package/testem together with libraries like Mocha or Jasmine.

I was following this tutorial on net tuts +

I have installed the testem npm module, but when I run it using command "testem" in cloud9's terminal window testem asks me to open a new tab in "localhost:7357"

Generally to preview workspace files in cloud9 I would go to https://c9.io/username/folders.../workspace/folders.../index.html

Since I am on the cloud9 server, I wanted to know if it is possible to open this 'localhost' link from the browser, and if yes, how would I do it?

(I tried 'localhost', '127.0.0.1', '0.0.0.0' inside cloud9's IDE, but it did not work).

Maybe I can access it differently?

Like "username.cl9.io/workspace:PORT" ?

If not, maybe it is possible to provide a link and port to testem (and by any chance how would one do it ?). I know in cloud9 you can use process.env.IP and process.env.PORT to provide to different modules, but no idea on how to open such files later from the browser.

Any help will be appreciated.

like image 264
Plyto Avatar asked Apr 13 '13 17:04

Plyto


3 Answers

If you are running a node process: http://workspacename.username.c9users.io will be the link to get to it.

If you want to preview a particular file in the workspace: https://c9users.io/username/workspacename/workspace/filename.html

Example:

My name is bob, and my project name is mycoolproject.

Running node service link - http://mycoolproject.bob.c9users.io

Direct file preview link - https://c9users.io/bob/mycoolproject/workspace/index.html

like image 114
Kendell Avatar answered Oct 27 '22 22:10

Kendell


If you run testem with the host and port variables:

testem --host $IP -p $PORT

You should be able to connect from your browser by going to the root of your external server:

http://workspace.username.c9users.io/
like image 20
geaw35 Avatar answered Oct 27 '22 22:10

geaw35


I know this is a really late response, but I get the feeling that you simply just need the right hostname and you'll be in business. My method for getting C9's hostname is as follows:

If you open up a terminal and access the mysql command line by typing in

mysql-ctl start

followed by

mysql-ctl cli

which will take you to the MySQL command line interface, and then you can run this query:

SHOW VARIABLES WHERE Variable_name = 'hostname';

It will give you back your hostname under the column hostname which should look something like this:

yourUsername-yourProjectName-XXXXXXX

where the X's form a 7 digit number. You can use that as your hostname instead of localhost or 127.0.0.1 (which have never worked for most people and I'm not sure why people on other SO posts consistently suggest those). I have used this hostname before to sync my PHP scripts with my MySQL databases (before C9 implemented a built-in phpMyAdmin), and always had success with it.

like image 23
Graham S. Avatar answered Oct 27 '22 21:10

Graham S.