Connection to wss://ws.binaryws.com/websockets/v3?app_id=xx with failed with php Ratchet
To support,
i am have try using PHP for connectiong to Websocket server binary API.
First i am get repository with command like this :
_**C:>cd AppServ
C:\AppServ>cd www
C:\AppServ\www>mkdir rac
C:\AppServ\www>cd rac
C:\AppServ\www\rac>composer require ratchet/pawl
Using version ^0.3.5 for ratchet/pawl
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 13 installs, 0 updates, 0 removals
- Installing ralouphie/getallheaders (3.0.3): Loading from cache
- Installing psr/http-message (1.0.1): Loading from cache
- Installing guzzlehttp/psr7 (1.7.0): Downloading (100%)
- Installing ratchet/rfc6455 (v0.3): Downloading (100%)
- Installing evenement/evenement (v3.0.1): Downloading (100%)
- Installing react/event-loop (v1.1.1): Downloading (100%)
- Installing react/stream (v1.1.1): Downloading (100%)
- Installing react/promise (v2.8.0): Downloading (100%)
- Installing react/promise-timer (v1.6.0): Downloading (100%)
- Installing react/cache (v1.1.0): Downloading (100%)
- Installing react/dns (v1.4.0): Downloading (100%)
- Installing react/socket (v1.6.0): Downloading (100%)
- Installing ratchet/pawl (v0.3.5): Downloading (100%)
guzzlehttp/psr7 suggests installing laminas/laminas-httphandlerrunner (Emit PSR-7 responses)
react/event-loop suggests installing ext-event (~1.0 for ExtEventLoop)
react/event-loop suggests installing ext-pcntl (For signal handling support when using the StreamSelectLoop)
react/event-loop suggests installing ext-uv (* for ExtUvLoop)
ratchet/pawl suggests installing reactivex/rxphp (~2.0)
Writing lock file
Generating autoload files
3 packages you are using are looking for funding.
Use the composer fund
command to find out more!**_
then i write simple script :
<?php _**require __DIR__ . '/vendor/autoload.php';**_ /* sample work connection to websocket.org \Ratchet\Client\connect('wss://echo.websocket.org:443')->then(function($conn) { $conn->on('message', function($msg) use ($conn) { echo "Received: {$msg}\n"; $conn->close(); }); $conn->send('Hello World!'); }, function ($e) { echo "Could not connect: {$e->getMessage()}\n"; }); */ ---> this code success connect and response _**\Ratchet\Client\connect('wss://ws.binaryws.com/websockets/v3?app_id=23772')->then(function($conn) { $conn->on('message', function($msg) use ($conn) { echo "Received: {$msg}\n"; $conn->close(); }); $conn->send('{"ping" : 1}'); }, function ($e) { echo "Could not connect: {$e->getMessage()}\n"; });**_ ?>if i run the code, we have message error DNS not connect like bellow :
_**
C:\AppServ\www\rac>php -e index.php
Could not connect: Connection to ws.binaryws.com:443 failed during DNS lookup: DNS query for ws.binaryws.com failed: too many retries**_
Please help me, whats wrong with my code.
Regards.
Comments
This looks like a similar issue to this https://github.com/reactphp/dns/issues/84 . Basically some issue with making DNS requests. I would suggest they try using different DNS servers (Google's? ) if possible.