Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

totaljs in vm (vagrant box) #11

Closed
anoff opened this issue Jun 17, 2014 · 9 comments
Closed

totaljs in vm (vagrant box) #11

anoff opened this issue Jun 17, 2014 · 9 comments

Comments

@anoff
Copy link

anoff commented Jun 17, 2014

I have a ubuntu vm running under windows which is running the totaljs example. But i cant access them on localhost:8000 from my host machine.
If i have a minimal example with just a node server running on 8000 everything works fine. So firewall/proxy should not be a problem.
Also if i run totaljs locally on windows it works fine.

Do i need any settings to run totaljs in a vm?

@anoff
Copy link
Author

anoff commented Jun 17, 2014

One finding: if i start total.js with my vm's IP framework.run(http, debug, 8000, '192.168.3.3');
i can access it via 192.168.3.3:8000 from the host.

But i don't understand why it doesn't work for localhost.

@petersirka
Copy link
Collaborator

Hi @extropianer, localhost is defined in host file and it's routed to:

127.0.0.1       localhost ::1             localhost

So my question: why do you need in URL localhost?
Thanks.

@anoff
Copy link
Author

anoff commented Jun 17, 2014

Thanks for the quick reply!

Usually when i run (node) apps in my virtual machine i can access them via 127.0.0.1 or localhost from my host machine.
But when i run total.js i need to add my virtual machine IP? This works but i wonder why it is like that. I am used to 127.0.0.1

@petersirka
Copy link
Collaborator

Can you access into your virtual machine via 127.0.0.1 or localhost?
Is this possible? I think that no.

But when i run total.js i need to add my virtual machine IP?
Yes, but I don't know what VM you are using.

@anoff
Copy link
Author

anoff commented Jun 21, 2014

Sorry for the late reply.
I am using vagrant box with port forwarding on 3000 (my usual port) and 8000 (for totaljs default).
If i make an express server:

var express     = require('express');
var app         = module.exports = express();

app.get('/', function (req,res) {
    res.send('hello world');
});

var port = process.env.PORT || 8000;
app.listen(port, function() {
    console.log('Listening on ' + port);
});

..everything works. So port forwarding is set up correctly. And i can access the website from outside the VM at localhost:8000 or 127.0.0.1:8000.
If i use total.js the same way it does not work.

Screenshots:

  1. http://imgur.com/CzaedZD basic express server on localhost:8000 works
  2. http://imgur.com/EDltxil totaljs example with local IP works
  3. http://imgur.com/69kdgwI default totaljs example localhost:8000 does not work

Now that i found out my VM local IP works i can start enjoying totaljs :)
Feel free to close this issue. If you want to find out why localhost:8000 does not work i can provide you with more information if needed.

@petersirka
Copy link
Collaborator

I don't know to help with it.
Sorry.

@meongx
Copy link

meongx commented Apr 21, 2015

Sorry to necro, but i have same problem

In the spirit of keeping our dev machine as close to production, we use VM for dev server with similiar image as deploy server. For simplicity we use port forwarding on dev server (similiar to @extropianer)

In my opinion, port forwarding doesn't work because totaljs binds to one listen address (default to 127.0.0.1)

Is there any way to make totaljs listens to ANY (*) address?

I tried using options.ip = '*', doesn't work because the address is non resolvable. Setting it to empty string options.ip = '' reverts back to default (127.0.0.1)

@petersirka
Copy link
Collaborator

Try to set options.ip = 'auto' and give me a feedback.
auto sets ip to undefined.

Thanks!

@meongx
Copy link

meongx commented Apr 21, 2015

setting options.ip = 'auto' does the trick

thanks a lot for the solution and fast reply :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants