Q
Q
qtohabr2014-11-10 11:28:23
PHP
qtohabr, 2014-11-10 11:28:23

Is it possible to implement a PHP daemon that will keep a permanent connection to the websocket server?

The essence of the situation:
There is a site and there is a call-center (websocket-server located on a server different from the site).
The site needs to receive up-to-date information from this web socket server, the information that the site receives is the same for all users (the number of free telephone lines).
Now it's implemented like this: each visitor, each time they go to the site's pages, establishes a connection to the websocket server via javascript and receives this data. As a result, a large number of connections are created and the websocket server crashes.
It is not possible to change anything on the websocket server.
How it should work:
A PHP daemon is launched on the site server, which establishes one connection to the websocket server and receives up-to-date information every N seconds and writes it to a file.
Question:
Is it possible to implement a PHP daemon that will keep a permanent connection to the websocket server? If so, what additional libraries are needed for this?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry Entelis, 2014-11-10
@DmitriyEntelis

Really, there is for example daemon.io

As a result, a large number of connections are created and the websocket server crashes.
How much is big? Why is it falling? Maybe the memory is leaking somewhere?

S
Sergey, 2014-11-10
Protko @Fesor

try reactphp + libev as a basis for the daemon.

S
Sergey, 2014-11-10
@begemot_sun

I never understood people who try to make PHP more than it is. PHP is not designed to run as a daemon.
You are thinking correctly that you are trying to write a proxy server. But PHP is a bad choice.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question