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

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

Open
exzizt opened this issue Jan 29, 2018 · 5 comments
Open

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

exzizt opened this issue Jan 29, 2018 · 5 comments

Comments

@exzizt
Copy link

exzizt commented Jan 29, 2018

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
Copy link

Dkendal commented Jan 30, 2018

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
Copy link
Author

exzizt commented Jan 30, 2018

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
Copy link

Dkendal commented Jan 30, 2018

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
Copy link
Author

exzizt commented Jan 30, 2018

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
Copy link

shana commented Feb 14, 2018

@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)

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