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

connecting the client to a server outside localhost #37

Closed
erelsgl opened this issue Jan 3, 2013 · 5 comments
Closed

connecting the client to a server outside localhost #37

erelsgl opened this issue Jan 3, 2013 · 5 comments

Comments

@erelsgl
Copy link

erelsgl commented Jan 3, 2013

Following the example on the readme, I built an example application with server and client. The client code in the readme is:

       var socket = io.connect('http://localhost:81');

This worked well on my computer, but when I tried to deploy both client and server to another machine, and tried to access the client from my machine, it didn't work, because the "connect" looked for the server on my machine (which is, for the client, the "localhost"...)

Maybe this is a documentation issue - explain how to deploy a client-server application.

@mrniko
Copy link
Owner

mrniko commented Jan 3, 2013

Do you use correct server url? You should use host or ip address in url, not localhost in this case.

@erelsgl
Copy link
Author

erelsgl commented Jan 3, 2013

OK, so maybe the client in the example should contain some expression that
automatically takes the correct url...

On Thu, Jan 3, 2013 at 6:58 PM, Nikita Koksharov
notifications@github.comwrote:

Do you use correct server url? You should use host or ip address in url,
not localhost in this case.


Reply to this email directly or view it on GitHubhttps://github.com//issues/37#issuecomment-11851186.

@mrniko
Copy link
Owner

mrniko commented Jan 6, 2013

"automatically takes the correct url..." Could you provide the code example for this?

@erelsgl
Copy link
Author

erelsgl commented Jan 6, 2013

Here is what I use:

var serverpath = location.protocol=='file:'?
"http://localhost":
location.protocol+"//"+location.host;
var serverport = 8090;
socket = io.connect(serverpath+":"+serverport);

On Sun, Jan 6, 2013 at 12:22 PM, Nikita Koksharov
notifications@github.comwrote:

"automatically takes the correct url..." Could you provide the code
example for this?


Reply to this email directly or view it on GitHubhttps://github.com//issues/37#issuecomment-11926651.

@mrniko
Copy link
Owner

mrniko commented Feb 1, 2013

Map server on ip or real domain, not localhost.

@mrniko mrniko closed this as completed Feb 8, 2013
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

2 participants