Ratchet
Ratchet copied to clipboard
Sudden Connection Termination
I am currently working on a chat app. I was able to connect, send and receive messages between clients. It was all going well. Except that i am having a slight issue that I cannot find the solutions anywhere. On the first time the client sends a message, their connection gets terminated, then automatically reconnects once again. There's no Error occurring. it just disconnects and reconnects automatically.
What are the usual causes for this? is there any way to prevent this?
Here's a link to the chat app im working on. its still unfinished.
https://github.com/jovelluna12/phpratchet-chat-realtime
A few points:
- Don't use the build-in MySQL functions PHP provides, use https://github.com/friends-of-reactphp/mysql instead
- Set up
on('error', fn)
handlers on the relevant objects - Capture and log errors for promises
@WyriHaximus what are the best practice if we have to use built-in extensions like PDO? I assume the reactphp based mysql library doesn't support PostgreSQL and other database, there also seems no support for statement preparation etc. to avoid sql injection.
@zhiyong80 Use https://github.com/voryx/PgAsync for PostgreSQL, and @clue is working on something on a higher level AFAIK. The statement preparation can be PR's into friends-of-reactphp/mysql of course
@WyriHaximus thanks and happy new year.
@zhiyong80 You're welcome, and a happy new year :fireworks: .