I created real time chat with long-polling. It works as follows:
First, user sends a request to the server. The server gets the request and waits for a new message.
If new message comes, it will push a message to the user's browser (if the request closed, then browser will resend it). If the server waited more than 3 min, the request will be cancelled and new one will be sent.
On the server, I used PHP. In PHP, I just check message count after every 600 milliseconds. If it is greater than the previous count, the server will get new messages and send them to the browser as responses.
The problem is that I get max_user_connection
error, even though I close mysqli connections after every SQL check in the database.
If I do not close mysqli, error happens more often.
How I can solve this problem? (For now My host is Hostgator and plan is shared)