battle-snake / battle_snake

AI Programing Competition Game Server
GNU Affero General Public License v3.0
12 stars 11 forks source link

[error] Could not check origin for Phoenix.Socket transport. #30

Open exzizt opened 6 years ago

exzizt commented 6 years ago
23:08:48.538 [error] Could not check origin for Phoenix.Socket transport.

This happens when you are attempting a socket connection to
a different host than the one configured in your config/
files. For example, in development the host is configured
to "localhost" but you may be trying to access it from
"127.0.0.1". To fix this issue, you may either:

  1. update [url: [host: ...]] to your actual host in the
     config file for your current environment (recommended)

  2. pass the :check_origin option when configuring your
     endpoint or when configuring the transport in your
     UserSocket module, explicitly outlining which origins
     are allowed:

        check_origin: ["https://example.com",
                       "//another.com:888", "//other.com"]

I run the app with Docker:

docker pull battlesnake/battle_snake
docker run -it -p 3000:3000 battlesnake/battle_snake

I then try to create a game with my snake URLs and get the above error message. Note that everything works fine with the 2017 server. Docker app is running on 192.168.99.100. My LAN is 10.104.35.xxx. An online snake on a hosting site also gets the same error message.

Dkendal commented 6 years ago

What url are you visiting to view the game? Please ensure that you're visiting it at http://localhost:3000, otherwise you will receive the transport error (it's a CORS check).

exzizt commented 6 years ago

I have to go to "192.168.99.100:3000" since it is running the app in a docker virtual machine. Using localhost would resolve to my host computer's IP and not work.

Dkendal commented 6 years ago

Okay I understand now. Getting this to work with different hosts will require modifying the Dockerfile to accept a hostname to override env it currently has.

In the meantime, can you run with --net=host and see if that allows you to connect via localhost:3000?

exzizt commented 6 years ago

I tried that out and it didn't work. I can still only connect via "192.168.99.100:3000". The command I ran is: docker run -it -p 3000:3000 --net=host battlesnake/battle_snake

On another note, since I have Windows 10 Pro I am able to use "Docker for Windows" to run the app (after enabling Hyper-V). This runs the app on my host machine (localhost:3000) and everything is working fine.

However, it would still be nice to get to the bottom of this issue as I'm sure other people will have it and not many people have Windows 10 Pro.

Edit: I am still willing to troubleshoot!

shana commented 6 years ago

@exzizt Change the HOST environment variable that's in the Dockerfile (https://github.com/battle-snake/battle_snake/blob/master/Dockerfile#L90) to have the ip of your public network. I ran the container with kitematic and changed it there, not sure how to do that in the docker cli (but I'm sure there's a way)