0

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.

1 Answer 1

0

with the help from @WyriHaximus i managed to solve this.

ive created a ratchetpawl websocket client with the same loop as ratchet websocket server's loop. and now its non blocking!

see my repository for code solution.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.