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

Sending Messages to Ratchet server with Pawl #50

Closed
ThatsARapp opened this issue Jul 25, 2017 · 3 comments
Closed

Sending Messages to Ratchet server with Pawl #50

ThatsARapp opened this issue Jul 25, 2017 · 3 comments

Comments

@ThatsARapp
Copy link

I am running a websocket server with Ratchet. The problem is when I have the server execute shell scripts based on incoming messages, I need there to be a way to let the server know that the script is finished executing. My solution was for the shell scripts to call a php script that sets up a client using pawl, and then sends a message to the server informing it of the completed task. Whenever I do this, the server hangs, and needs to be restarted. When I call php script directly from the command line, a socket is created, and a message is sent, but when the server calls the same script with "exec" or through executing a sh script which then calls the php script, the server hangs, produces no errors, and needs a restart. I imagine it has something to do with the client trying to connect to itself because when I use an invalid ip, it produces an error, but when I use the actual ip, it hangs. Please help.

@clue
Copy link
Member

clue commented Jul 25, 2017

HI @Mrmrprofessional! It looks like your exec() call blocks your event loop until it's finished and thus your server has no way of accepting any new connections until this script finished. As an alternative, you may want to use https://github.com/reactphp/child-process to execute a child process without blocking. This will also simplify reacting to when the script finished and you should no longer need your script to message back at all.

I hope this helps 👍

@ThatsARapp
Copy link
Author

ThatsARapp commented Jul 25, 2017 via email

@clue
Copy link
Member

clue commented Jul 25, 2017

Depending on what you're trying to do a cron job may or may not be the best tool for the job :-) If it works for you, I see no reason to change this 👍 As an alternative, you may want to spin up a periodic timer to send your messages and perhaps keep the websocket client connection open.

@mbonneau mbonneau closed this as completed Oct 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants