4
votes

I currently have an application that is using the Pusher API to enable real time messaging and would like to remove my dependency on Pusher.

I am keen to keep my current application as it stands and connect over websockets to a channel on an Phoenix app that is a completely separate application on a separate instance. Reasoning for this is it will allow me to separately scale the phoenix app when there is a large number of messages.

Is this possible? I have experience of using Socket.IO and this supports this functionality by specifying the location of the Socket application when trying to connect.

1

1 Answers

3
votes

Yeah it's possible, you can set the option :check_origin as explained in lib/phoenix/transports/long_poll.ex source code:

https://github.com/phoenixframework/phoenix/blob/master/lib/phoenix/transports/long_poll.ex#L26

  • :check_origin - if we should check the origin of requests when the origin header is present. It defaults to true and, in such cases, it will check against the host value in YourApp.Endpoint.config(:url)[:host]. It may be set to false (not recommended) or to a list of explicitly allowed origins