-1

When I execute the following piece of code in the app.js file

const WebSocket = require('ws');

const ws = new WebSocket('wss://stream.binance.com:9443/ws/!miniTicker@arr');

ws.on('message', function (data){
    //const result = JSON.parse(data);
    console.log(data);
});

I get the following error and I cannot receive data.

enter image description here

CherryDT
  • 25,571
  • 5
  • 49
  • 74
P B
  • 21
  • 2
  • Do not post (only) images of text. Copy the text instead. You can include the image _additionally_ if it has some benefit like colors that are missing otherwise, but there should always by a textual version as well, otherwise it's a problem for searchability and accessibility. – CherryDT Aug 09 '22 at 07:26

1 Answers1

0

10.10.34.34 (what your DNS server resolved stream.binance.com to) is a local IP address! You are not even reaching Binance. It's probably a captive portal or some firewall.

Open that IP address in the browser and check whether you get some sort of web interface that gives you a clue about what is blocking your request. You can also try changing your DNS server to Google (8.8.8.8) or some other public DNS server instead of relying on your router.


Update:

In your comment you mentioned your DNS server is 178.22.122.100 (i.e., shecan.ir). If I try to resolve the domain with that server, I also get nonsensical results (10.10.34.34 and d0::11). According to this book, this is part of Iranian censorship, and your ISP would handle this IP address to show a page about this domain being blocked if you'd open it in a browser.

So, an alternative public DNS server without censorship such as 8.8.8.8, 1.1.1.1 or 9.9.9.9 should help. If this doesn't work then those DNS servers are also blocked by your ISP and you would need to use a VPN or other means of bypassing government censorship.

CherryDT
  • 25,571
  • 5
  • 49
  • 74
  • My DNS server is: DNS: 178.22.122.100 – 185.51.200.2 The problem still exists. I really don't know what to do. – P B Aug 09 '22 at 07:37
  • Did you try the two things I said? – CherryDT Aug 10 '22 at 08:17
  • Yes. I tried. But unfortunately, I don't get any results. I even tried another way. There is still a problem. Another method is available in the link below. https://stackoverflow.com/questions/73297236/unable-to-connect-to-binance-websocket – P B Aug 10 '22 at 18:13
  • If I resolve this domain with 178.22.122.100, I do get nonsensical results. Perhaps Iran is trying to censor Binance. But with 8.8.8.8 as I suggested, the correct IP addresses are returned. So, as I said, your DNS server is the problem. Use another one. – CherryDT Aug 10 '22 at 21:05
  • Also, I'm not sure what you mean by you tried and don't get results, because the first thing I asked you to check (opening the IP 10.10.34.34 in the browser) should have shown you an Iranian filter page notifying you that access to this page is blocked by your ISP (according to [this book](https://books.google.at/books?id=NWWADwAAQBAJ&pg=PA69&lpg=PA69&dq=%2210.10.34.34%22&source=bl&ots=hjMREAzFxE&sig=ACfU3U1dwV0jbyYxKxiDE_hCqNY3OL0KkA&hl=de&sa=X&ved=2ahUKEwidvvrolr35AhXNPOwKHR6VBHQQ6AF6BAgSEAM#v=onepage&q=%2210.10.34.34%22&f=false) at least). This should have told you what's going on. – CherryDT Aug 10 '22 at 21:08
  • I used large and public DNS servers. (8.8.8.8, 1.1.1.1 or 9.9.9.9) But the problem still exists. I also use a siphon (For Windows OS) filter. But the problem still exists. https://s3.amazonaws.com/psiphon/web/60l3-nnss-6gsn/en/download.html#direct Thank you for your response. – P B Aug 11 '22 at 05:45
  • Also, by opening that IP address in the Chrome browser, (opening the IP 10.10.34.34 in the browser), the message I receive: This page isn’t working10.10.34.34 didn’t send any data. ERR_EMPTY_RESPONSE – P B Aug 11 '22 at 05:54