Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to check if push server is online? #602

Open
luX0r-reload opened this issue Jan 24, 2018 · 4 comments
Open

How to check if push server is online? #602

luX0r-reload opened this issue Jan 24, 2018 · 4 comments
Labels

Comments

@luX0r-reload
Copy link

Hello,
thanks for your nice works!
I'm using your push server sample code and it works fine.
I need to send data to push server only if push server is up and running.

$context = new ZMQContext();
$socket = $context->getSocket(ZMQ::SOCKET_PUSH, 'my pusher');
$socket->connect("tcp://localhost:5555");
$socket->send(json_encode($entryData)); /* run this line only if socket is up and running */

How I can do it?

Thanks in advance

L.

@mbonneau
Copy link
Member

mbonneau commented Feb 1, 2018

@luX0r-reload Do you still need this information if you are switching off of ZMQ? (ratchetphp/Pawl#70)

@luX0r-reload
Copy link
Author

I'm not switching. My hosting provider installed ZMQ on VPS and all works fine now.
So... yes, If possible I need this information for secure my application.

@mbonneau
Copy link
Member

mbonneau commented Feb 10, 2018

@luX0r-reload If you need to detect when the websocket server is up, consider connecting with a websocket client library.

@Rathdor
Copy link

Rathdor commented Apr 9, 2018

Hi, i have the same problem. Websockets with pusher works fine but i would like to know if server is up when i cast: "$socket->send(json_encode($entryData))".

SEND always return an empty ZMQSocket Object.

Message stays in queue and were received when server runs.

If i convert it into a non persistent with: "$context = new ZMQContext(1, false);", then SEND returns same result but the page remains blocked until server is up and running.

Is there a way to know if the message sent is in queue or it's sent succesfully?

I have tried this: "$socket->send(json_encode($entryData),ZMQ::MODE_DONTWAIT)" but same result.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants