chat with socket ajax php and nodejs?

I am writing a chat application for mobile & web using PHP and nodejs-socket.io.

I am using Android to post messenger to PHP - PHP to create a new socket (net library on nodejs) and that response messenger to friend via nodejs.

A (via HTTP Request)-> PHP (via socket)-> NODEJS (via socket.io)-> B (web - websocket / android)

I was trying A->NODEJS->B use all by socket.io, but the message is slow when the number of users increases.

I found the time for sending messenger from nodejs to B device (chatter) very fast, but socket PHP sending messenger to NODEJS is slow.

I see the socket in PHP/nodejs is opening and closing many times in a short period of time. Please help me make my application run faster, or suggest a solution?

I expected to try using java, but can anyone tell me anything about websocket performance, i.e. socket.io vs. java socket speeds?

Thank you.

Websocket performance really good, really fast. I tested on Chrome (PC) but not on mobile phone yet.

And Java socket is simple and easy to use. Why don't you use java socket to connect directly from Android -> NODEJS without making any HTTP request and PHP bridge?

The reason why PHP socket repeatedly open and close: there are many reason make your code open and close repeatedly, may be there are no loop in your PHP code to keep the connection. Can you show your detailed code of the problem please?