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

Couldn't Run The Example Smoothly #76

Closed
ZeroHackeR opened this issue Aug 29, 2017 · 8 comments
Closed

Couldn't Run The Example Smoothly #76

ZeroHackeR opened this issue Aug 29, 2017 · 8 comments

Comments

@ZeroHackeR
Copy link

ZeroHackeR commented Aug 29, 2017

Dear there,

When I tried the example:

git clone https://github.com/gamestdio/colyseus-examples.git
cd colyseus-examples
npm install
npm start

I sometime got this error and it stopped.
I couldn't find where it is coming form as well.

Error: connect ECONNREFUSED 127.0.0.1:80
    at Object.exports._errnoException (util.js:1018:11)
    at exports._exceptionWithHostPort (util.js:1041:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1086:14)
worker 15136 died. Respawn.
@endel
Copy link
Member

endel commented Aug 29, 2017

Hi @ZeroHackeR,

I've never seen this error. Can you provide the version of node and operational system you're using? Thanks!

@Federkun
Copy link
Contributor

Federkun commented Aug 29, 2017

Same problem. PORT=80 npm start works fine. With every other port it doesn't.
v. node: v8.1.4, running on docker (ubuntu).

@Federkun
Copy link
Contributor

Federkun commented Aug 29, 2017

I didn't have anything running on port 80. That was the problem. If I start a webserver on port 80, I don't get any error when colyseus-examples is running on other ports.

@endel
Copy link
Member

endel commented Aug 29, 2017

Oh, I see. Thanks @Federkun!

@ZeroHackeR probably has the PORT environment variable set to 80 for some reason. Using any other (unused) port should be fine!

I've just updated the examples to use a fixed port number instead of prioritizing process.env.PORT.

@Federkun
Copy link
Contributor

Mh, I don't think that's the case. I'm trying to understand why colyseus require an unrelated process running on port 80 to work correctly, but the error message doesn't offer any meaningful information..

@endel
Copy link
Member

endel commented Aug 30, 2017

@Federkun Colyseus spawns a match-making process for internal communication only, I'm not sure if this line could be causing the problem: https://github.com/gamestdio/colyseus/blob/c59901e637fc7538f3ea4267a81360c26300e2ee/src/matchmaking/Process.ts#L13

@Federkun
Copy link
Contributor

Federkun commented Aug 30, 2017

After some debugging I'm sure that the problem is here:
https://github.com/gamestdio/colyseus/blob/3f0a1ee8ee1d03a9c59459d5348c7c3d58e139e0/src/cluster/Worker.ts#L89
ClientRequest uses the default port (80) instead of the ephemeral port that's been used here:
https://github.com/gamestdio/colyseus/blob/765401e9acab6c09d92a01cea2eeeefc93214110/src/ClusterServer.ts#L112

I'm not sure about the api of ClientRequest, but if we can change the port to server.address().port, it should fix the problem. If I can find how to do it, I'll apply a patch today.

@Federkun
Copy link
Contributor

I had to dig the nodejs repository to learn how to do it. I'll do a pull request in a second, so you can review it.

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