Answer the question
In order to leave comments, you need to log in
Simple implementation of notifications from the server to the browser?
Let's say I'm doing a chat.
You need to notify clients when certain events occur.
The main site is written in PHP, and this is where the events appear.
The easiest way I see is:
1) On Node.js (socket.io), write a server (and put it behind nginx), which will be connected to the browser via WebSocket.
2) When an event occurs in the PHP part of the project, we send a message to rabbitmq.
3) If there is a message in rabbitmq, we send it to the Node.js daemon to the necessary clients in the browsers.
4) Monitor the Node.js server to the supervisor.
I don't like the technology zoo for this task.
How sooner can you?
Answer the question
In order to leave comments, you need to log in
And what exactly in a set of technologies confuses? Well, as an option, you can replace node.js with Ratchet, -1 YP will be in the list.
So in fact, do not subtract, do not add.
easier - longpoling.
on the client using ajax send a request to the server. Set a timeout of 1 minute. On the server, you make a loop that returns a value if there are changes + sleep(1) in the iteration. Well, set the time - as convenient. in case of changes - send data - ajax accepts and notifies.
For me, the easiest way was to use server sent events
For web sockets, in principle, node js is not necessary, the php script can also be made to be a demon.
And communication between the daemon and the site is easier, yes, through rabbitmq.
As I understand it, you don’t want to put the node in the zoo, then take Go, it’s simple, beautiful, a minimum of dependencies, it will be easier to scale
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question