Qqwy
Hello everyone!
We’re building the seamless chat service Planga. (An official release will come soon!
)
Communication between the user’s browser with the other users is done through a Phoenix Channel (either using a websocket-connection or the fallback longpoll-transport).
Now, we’ve turned off CSRF-prevention checking, since any site is allowed to perform requests to the service (and it is then authenticated using their API key).
However, it seems that by default, Phoenix does not allow you to connect to websockets-over-ssl (wss:// as protocol) if the client application the user is visiting is a non-https website. The same is true for the longpoll transport (Phoenix disallows https://-based longpolling from a http website).
In development, where Phoenix runs without SSL itself, this is obviously not a problem, but since we’d like to allow developers that want to use our API to test things out with the system without them having to set up HTTPS certificates for their locally running development environments, we’d like to change this behaviour.
How can this behaviour be changed?
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #ai
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 4- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
chrismccord
If I understand your issue correctly, this is not a phoenix thing, but a browser thing. Browsers will generally disallow mix content. For the phoenix.js client, if you leave off the protocol, it will inherit ws or wss based on the browser window’s protocol. Phoenix.js and the elixir channels side will gladly accept wss traffic. If you let the client inherit the protocol, ie
let socket = new Socket("//yourhost.com/socket"). Provided your phoenix endpoint is configured for:httpand:httpsthen you are all set.OvermindDL1
As I recall and that which a quick google search seems to confirm, an
httppage’s javascript can loadwsswebsockets, but anhttpspage’s javascript cannot load awswebsocket.Qqwy
Thank you both!
What seems to be going on here is the following:
"//example.com/socket".http://example.com/socket/websocket?vsn=2.0to set upws://example.com/socket/websocket?vsn=2.0.What would be the best way to resolve this? I’d rather have people on HTTP still try to connect to wss resp. https chats.
OvermindDL1
Why not just always do
"wss://example.com/socketinstead?