Using Textalk/Websocket-Php to Connect with Socket. Io
I've a Problem with Connecting to Socket. Io Server Using Textalk/Websocket-Php Package on the Node(Websocket) Side I've: Server = httpServ. createServer()...
I've a problem with connecting to socket.io server using textalk/websocket-php package
On the node(WebSocket) side I've:
server = httpServ.createServer().listen(process.env.PORT); //3000
let socketCorsConfig = {
origin: "*:*"
}
const io = require('socket.io')(server, {
path: '/ws',
serveClient: false,
pingInterval: 10000,
pingTimeout: 5000,
cookie: false,
cors: socketCorsConfig
});
io.use(async (socket, next) => {
console.log('middleware');
...
});
io.on('connection', async socket => {
console.log('connection, socket: ' + socket.id);
...
});
On the PHP(Symfony) side I've:
use WebSocket\Client as WSClient;
...
$wsClient = new WSClient('ws://php-websocket:3000/ws/?EIO=4&transport=websocket');
while(true){
$message = $wsClient->receive();
dump('Data', $message);
}
$wsClient->close();
In the console the output is:
Data 0{"sid":"H3I27EP0LH-JOJWvAAAI","upgrades":[],"pingInterval":10000,"pingTimeout":5000,"maxPayload":1000000}
Data
Data 0{"sid":"nIij79dNorR_kYxOAAAJ","upgrades":[],"pingInterval":10000,"pingTimeout":5000,"maxPayload":1000000}
In Connection.php line 464:
Client read timeout
Response indicates that PHP Client was able to reach the WS server and received the handshake. Unfortunately it failed to establish permanent connection.
Do you have any suggestions on what might be the problem here?
I should also mention, that there's no problem with connecting to WS server using socket.io client.