0

I am trying to run the following code from my chrome browser

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);
});

But what I got is this: enter image description here

Why it is converting my WSS url to Https? and this problem is for this binance streaming api only I am not getting this problem when I use the following url

wss://streamer.cryptocompare.com

So, how should I overcome this problem? Thanks.

P.S. I have tried this code on both Firefox and Google Chrome both are behaving same for the Binance Websocket Api URL.

Mukarram Ishaq
  • 748
  • 1
  • 8
  • 18

1 Answers1

0

After much struggling, I still don't know why WSS url gets converted to HTTPs but now I know how to overcome it.

Use WebSocket class of JavaScript directly or a wrapper/library which uses WebSocket class of JavaScript internally then you won't get the above issue.

P.S.
This answer is just to save someone like me from going through the pain of days of searching and frustration, though part of the above question is still unanswered :) .

Mukarram Ishaq
  • 748
  • 1
  • 8
  • 18