im tring to create an adapter in php to forward messages from javascript client to nodejs server and vice versa.
WebSockets:
nodejs server: ws
php server: RatchetPHP
php client: RatchetPawl
Code:
websocket server in php: chatWSServer.php
connection class: connection.php
javascript client:
connection = new WebSocket('ws://localhost:9000');
connection.onmessage = (e) => {
console.log(e.data);
}
connection.onopen = (e) => {
console.log("connection established!");
}
connection.addEventListener('message', (resData) => {
console.log("got message:", resData);
});
Problem:
i try to open a connection to the nodejs websocket server (localhost:8889), on javscript client connection to php websocket server (localhost:9000): chatWSServer.php - createConnection() and its working, but when the javascript client try to send a message i get:
Failed to execute 'send' on 'WebSocket': Still in CONNECTING state.
i think its because ratchet pawl connector loop is running - when i comment: loop->run()
the client is able to send messages.