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.
2Related questions 5085 Reference Guide: What does this symbol mean in PHP? (PHP Syntax) 3055 Deleting an element from an array in PHP 2714 Why shouldn't I use mysql_* functions in PHP? Related questions 5085 Reference Guide: What does this symbol mean in PHP? (PHP Syntax) 3055 Deleting an element from an array in PHP 2714 Why shouldn't I use mysql_* functions in PHP? 2773 How can I prevent SQL injection in PHP? 0 Why socket.io returns "Bad handshake method"? 687 Differences between socket.io and websockets 2273 How does PHP 'foreach' actually work? Load 4 more related questions Show fewer related questions
Reset to default