marceloandrader

marceloandrader

Hi there,

I have a PHP app (it’s big can’t migrate it to elixir) so for pseudo real time communications, I’m using a request that uses Server Sent Events that start a redis subscribe to specific channels and on each message I sent to the client, so I can send notifications/progress/etc to the client from the server. The issue is that this requests are long lived, and they are using too much resources in the server.

I’m trying to move to websockets instead of SSE, but in php it looks super complex. I was wondering if I can use channels outside elixir, looks like the way to send messages is simple enough I can write a client in php, but tried to add the js socket client to my app and it didn’t work. It’s trying to open the websocket connection to the same host the website is running instead of the webserver where phoenix app is running, not sure how to specify the right host in the js client.

And what is the best way to secure this scenario?

Thanks in advance

Showing Posts 1 to 4

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

Hey @marceloandrader let me see if I understand the scenario you are trying to make work.

  1. You have an existing PHP app that serves HTTP requests, including SSE.
  2. You have a Phoenix app that runs on a different domain (host)
  3. You want your pages from the PHP app in (1) to include Javascript that talks to (2)?
marceloandrader

marceloandrader OP

Yes exactly. I can make it run the phoenix app behind nginx on the same domain. Haven’t tested that yet.

Hermanverschooten

Hermanverschooten

If what you want to do is, connect to the channels from the JS side. You only need to include the phoenix javascript and setup the connections as it is done in a normal phoenix app.

marceloandrader

marceloandrader OP

Thank you all, reporting that it worked flawlessly. For the PHP side talking to elixir, I just decided to add an endpoint to receive the message and broadcast it.

Only thing left is authentication, in the examples I see that from the js tries to send a userToken, but in my case I’ll need to create this token in PHP to then send in my js file.

Is there any other implementations besides elixir of this signing method:

Phoenix.Token.sign

?

— All posts loaded —

Where Next? Top

Trending in Questions Top

katta
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
achenet
Hello, I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind. However, when I launch mix phx.server, I get an error...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
mnkhod
So i have been using ash framework for a while and i love it. However currently the issue im having with ash framework is the error handl...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews