I'm having trouble connecting to binance futures' websocket server in php.
In the example below in BINANCE SPOT it works:
<?php
$sock = stream_socket_client("tls://stream.binance.com:9443",$error,$errnum,30,STREAM_CLIENT_CONNECT,stream_context_create(null));
if (!$sock) {
echo "[$errnum] $error" . PHP_EOL;
} else {
echo 'Conected!';
}
But in the example below in BINANCE FUTURES it doesn't work. Does not connect to server.
<?php
$sock = stream_socket_client("tls://fstream.binance.com",$error,$errnum,30,STREAM_CLIENT_CONNECT,stream_context_create(null));
if (!$sock) {
echo "[$errnum] $error" . PHP_EOL;
} else {
echo 'Conected!';
}
The error message reported is this:
PHP Warning: stream_socket_client(): unable to connect to tls://fstream.binance.com (Failed to parse address "fstream.binance.com") in D:\p_local\atual\ws\wsf.php on line 2
Does anyone know why the second option doesn't work?
link to futures binance websockets documentation: https://binance-docs.github.io/apidocs/futures/en/#websocket-market-streams
*I'm using native php server in command line in windows environment. Thanks in advance.