Please share the experience of creating a chat in PHP or javascript. I spent a whole day yesterday exploring WebSocket, even rented a VDS, connected this dll or don't know what to call it. I installed ready-made PHP / WbSocket chat scripts on it and none of them worked. Just spent 1 day and money.

There was experience in creating a chat in PHP / Mysql but due to frequent requests to the database, hosting temporarily disables access. So already disappears.

I thought I would implement it on files or on sqlite3, but I don’t know what the upload to the server will be if for example 100 people will be in the chat and each will receive requests for example 1 time in 5 (10) seconds. Where can I see or who knows this is bad or completely horrible?

If someone helps me to figure out why my WebSocket chat does not work for me, I will be very grateful.

  • It seems to me that choosing php for chat implementation is not a very good idea. This is just a very weak php niche. - s976

1 answer 1

If you want to chat on php , then use LongPoll . By the way, there are many examples of implementation on the Internet.

But if you need WebSocket , then use node.js.

There are many ready-made libraries for implementation, for example http://socket.io/

  • Should node.js be used with socket.io? Or you can do on jquery? And another question: if WebSocket is not on the hosting, then socket.io will work? - Vladimir
  • There are many other implementations of WebSocket on node.js - antop95