mrniko / netty-socketio

Socket.IO server implemented on Java. Realtime java framework
Apache License 2.0
6.82k stars 1.65k forks source link

connecting the client to a server outside localhost #37

Closed erelsgl closed 11 years ago

erelsgl commented 11 years ago

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 commented 11 years ago

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

erelsgl commented 11 years ago

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/mrniko/netty-socketio/issues/37#issuecomment-11851186.

mrniko commented 11 years ago

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

erelsgl commented 11 years ago

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/mrniko/netty-socketio/issues/37#issuecomment-11926651.

mrniko commented 11 years ago

Map server on ip or real domain, not localhost.