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

Deploy can't connect client to endpoint #355

Closed
vittis opened this issue Jul 4, 2020 · 5 comments
Closed

Deploy can't connect client to endpoint #355

vittis opened this issue Jul 4, 2020 · 5 comments

Comments

@vittis
Copy link

vittis commented Jul 4, 2020

Hey, I'm having issues connecting the client to WS when deploying.

I'm using Node + React and for dev I use const client = new Client('ws://localhost:2567'); and works fine

Now I created a droplet in Digital Ocean, created a static build of the client and put it on server under build folder and serve like that:

app.get('*', function (req, res) {
  res.sendFile(path.join(__dirname, 'build', 'index.html'));
});

But when I access it on the browser I get connection failed. I tried localhost and the ip of the droplet but no success, the error on browser console is:

POST http://localhost/matchmake/joinOrCreate/life_room net::ERR_CONNECTION_REFUSED

Anyone know what endpoint or setup should I use to make it work? Thanks

@jakapps
Copy link

jakapps commented Jul 4, 2020

You must ensure that your colyseus server is correctly exposed to the internet. Localhost will not work at all, as the browser will only try to connect to locally hosted servers.

https://docs.colyseus.io/deployment/

@vittis
Copy link
Author

vittis commented Jul 4, 2020

@wrigggy Thanks for reply.

I did the steps under "Nginx configuration" from the link you sent. When I ssh into my droplet and run it the output is Listening on ws:__localhost:2567, I also get the index.html rendered in the browser so I think this step is fine. The issue is that it doesn't connect to colyseus.

I'm still unsure on what endpoint string should I put in the client in this line below as it's seem to be what's not working

const client = new Client('ws://localhost:2567');

@jakapps
Copy link

jakapps commented Jul 4, 2020

I'm still unsure in what endpoint should I put in the client in this line below as it's seem to be what's not working

const client = new Client('ws://localhost:2567');

You need to find the external ip address that your droplet is accessible with, and substitute it for localhost.

const client = new Client('ws://your-droplet-ip-address');

You should find it somewhere in your digital ocean dashboard.

EDIT: I'm assuming that you aren't using a domain name that is pointing to your droplet, in which case, you would just use the domain:

const client = new Client('ws://your-domain-name.com');

@vittis
Copy link
Author

vittis commented Jul 4, 2020

I still get POST http://<droplet_ip>:2567/matchmake/joinOrCreate/life_room net::ERR_CONNECTION_TIMED_OUT

I must've done something wrong in the nginx setup, I'll look better into it.

Thanks for the help and directions, it helped!

EDIT: Just noticed that I included the port, tried without it and it worked!
EDIT: Removed droplet IP as it's not relevant

@vittis
Copy link
Author

vittis commented Jul 4, 2020

My error was that I was including the port with the IP of the droplet, removed it and it worked. I'll close the issue now.

Thanks for the help @wrigggy!

@vittis vittis closed this as completed Jul 4, 2020
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