My attempt to execute the code from my Chrome browser was unsuccessful.
import io from 'socket.io-client';
const socket = io('wss://stream.binance.com:9443');
socket.on('connect', () => {
console.log('binance [socket] Connected');
});
socket.on('disconnect', (reason) => {
console.log('binance [socket] Disconnected:', reason);
});
socket.on('error', (error) => {
console.log('binance [socket] Error:', error);
});
The outcome is unexpected. It appears that my WSS URL is being converted to HTTPS. Interestingly, this issue only occurs with the Binance streaming API and not when I use the following URL:
wss://streamer.cryptocompare.com
How can I resolve this problem? Thank you in advance.
P.S. I have tested this code on both Firefox and Google Chrome, and they exhibit the same behavior for the Binance Websocket API URL.