That's not going to ruin websockets, but clearly it is an unnecessary overload of the server. Why do you use AJAX? Why don't you update the database directly from Node??
Those AJAX calls are going to hit the server permanently and will sure cause trouble. One of the reasons to use websockets (and also long-polling) is to avoid that excessive load. If both PHP and Node.js are on the same server, excessive load would slow down both.
When a user (aka socket) connects/disconnects, Node.js can add/remove that user to MySQL. If the Node.js server is on a different machine, allow MySQL remote connections for that separate server.
And the same with messages, update the database directly from your Node.js script.
Here there is a Node driver for MySQL: https://www.npmjs.org/package/mysql