Overv / WebCraft

Minecraft clone written in Javascript.
zlib License
387 stars 186 forks source link

multiplayer.html stops at "connecting to server..." #18

Closed Bayside308 closed 6 years ago

Bayside308 commented 6 years ago

Hello!

I'm using a Windows 10 computer to test this out locally. I'm using the npm http-server as my web server, which is functioning properly. I'm opening the page through localhost:8081/multiplayer.html, and it allows me to enter a name. After that, however, it just freezes at "connecting to server...".

I'm able to start the server.js file with no issues.

The web server outputs this error: "POST /socket.io/?EIO=3&transport=polling&t=L-PW7s9" Error (404): "Not found" Chrome outputs this error: POST http://localhost:8081/socket.io/?EIO=3&transport=polling&t=L-PVxHX 405 (Method Not Allowed)

Overv commented 6 years ago

Perhaps raise this issue with socket.io.

Bayside308 commented 6 years ago

Will do! Is there anything else I should be doing that I missed? I am supposed to run a web server, as the server.js doesn't do that, right?

Overv commented 6 years ago

Ah, the problem is that it expects the WebSocket server to be on the same origin (localhost:8081) whereas I think the server.js hosts it on port 80. The HTML and WebSocket stuff should be served on the same port or you need to change the connecting code in multiplayer.html.

I'm not sure how I ran the server when I worked on this project, but I may have used a reverse proxy to forward just the /socket.io/ stuff to server.js.

Overv commented 6 years ago

I just tested it on my own PC. I started the server with node server.js and browsed to http://localhost:3000/multiplayer.html. That works fine here.