smogon / pokemon-showdown

Pokémon battle simulator.
https://pokemonshowdown.com
MIT License
4.77k stars 2.79k forks source link

Unable to connect once server starts #8484

Closed mtullo27 closed 2 years ago

mtullo27 commented 3 years ago

I have gotten all code to compile, but whenever anyone (including myself) tries to connect to the url it states could not connect to server.

image

mia-pi-git commented 3 years ago

Firstly, you should be aware no one's gonna be able to connect to your localhost except for you (unless you port forward.) I guess my first question is, you're actually starting it with ./pokemon-showdown, right? Building and starting are different.

mtullo27 commented 3 years ago

sorry, I am very much new at this. I know no one will not be able to connect to ym local host

broil-x commented 3 years ago

Hello, I've experienced exactly the same issue. I posted about it in the Development discord as well.

I have run Showdown many times in the past, but not for a few months. I tried to again the other day and had the same issue.

localhost:8000 redirects properly to localhost.psim.us, but then all you get is "Couldn't connect to server!". This is all on the same machine that is running it.

mtullo27 commented 3 years ago

I was using node pokemon-showdown since I am on windows. How would i start the server on windows

Zarel commented 3 years ago

Unfortunately, our issue tracker is the wrong place for tech support. We do sometimes accept bug reports if they're sufficiently detailed to reproduce and fix, but this isn't that.

broil-x commented 3 years ago

I would respectfully ask you to reconsider. This is a pressing issue for me, as I run a side server for my university and at the moment cannot update my server. For now this isn't a huge deal as there haven't been any major changes recently, but when major changes are made I will be unable to update my server to reflect these.

As shown by this issue, I am not the only one experiencing this issue, and this is a major roadblock to anyone who maintains or wants to create a side server. I have also heard others in the Dev discord having the issue as well, which could result in a roadblock to development of the project.

I am happy to provide any details to attempt to shed more light on the issue, I just need to know what to share.

Thanks

KrisXV commented 3 years ago

fwiw I also am experiencing this, p sure all that's required to reproduce is running it on a windows OS

DaWoblefet commented 3 years ago

I am also experiencing this on Windows.

DaWoblefet commented 3 years ago

Looks like some sort of CORS bug?

Access to XMLHttpRequest at 'http://localhost:8000/showdown/info?t=1633116225794' from origin 'http://localhost.psim.us' has been blocked by CORS policy: The request client is not a secure context and the resource is in more-private address space `local`. localhost:8000/showdown/info?t=1633116225794:1 Failed to load resource: net::ERR_FAILED localhost.psim.us/:1 Access to XMLHttpRequest at 'http://localhost:8000/info?t=1633116226104' from origin 'http://localhost.psim.us' has been blocked by CORS policy: The request client is not a secure context and the resource is in more-private address space `local`. localhost:8000/info?t=1633116226104:1 Failed to load resource: net::ERR_FAILED localhost.psim.us/:1 Access to internal resource at 'http://play.pokemonshowdown.com/manifest.json' (redirected from 'http://localhost.psim.us/manifest.json') from origin 'http://localhost.psim.us' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

KrisXV commented 3 years ago

I am reopening this issue because I have tested on both public and private connections as well as two different browsers and have gotten numerous errors, ranging from:

Firefox: image

to

Chrome: image (when connecting to another server)

Zarel commented 3 years ago

Ah! Yeah, this is caused by a new CORS proposal that Chrome has started to implement.

In Chrome, it can be temporarily worked around by disabling:

chrome://flags/#block-insecure-private-network-requests

Here's hoping SockJS can fix it. To an extent, it's out of our hands. :(

Zarel commented 3 years ago

Well, hm. There's actually a way to work around this: Instead of using SockJS, directly use WebSocket. If WebSocket connections themselves can connect to localhost, the entire problem is solved at that step.

mtullo27 commented 3 years ago

Disabling that enables me to launch the webpage, but users cannot connect to my server using http://MYIP.psim.us/

mia-pi-git commented 3 years ago

Disabling that enables me to launch the webpage, but users cannot connect to my server using http://MYIP.psim.us/

You need to port forward to make it work with your IP. Generally wiser to use a VPS, though, but both of those are more of a question for Google.

Zarel commented 2 years ago

Well, hm. There's actually a way to work around this: Instead of using SockJS, directly use WebSocket. If WebSocket connections themselves can connect to localhost, the entire problem is solved at that step.

Good news! Turns out yes, this workaround works! There's no longer a need to use the Chrome flag... at least not until someone starts having a WebSocket vuln on an open localhost server. :p

brenoteles commented 1 year ago

I was having this problem and after a long time I found out that it was the uBlock that was causing it, I don't know why, but when I disable the extension the problem disappears.