2

I`ve tried to connect to the websocket api over getblock.io but it always fails. Here below is JS code. But HttpProvider works fine on "https://bsc-mainnet.web3api.com/v1/API_KEY".

web3ws = new Web3(new Web3.providers.WebsocketProvider('wss://bsc.getblock.io/mainnet/?api_key=API_KEY'));

if (web3ws.isConnected)
            console.log("Connected");
        else 
            console.log("Not Connected"); 

Am I missing something here ? Should i have to pay it first to able to use this service?

mathew sada
  • 77
  • 1
  • 6

2 Answers2

1

Our WebSockets for BSC have been working during all this time. The WebSockets which Petr Hejda meant is a tool used for event notifications. Currently, it's under development, we're working on its implementation.

We're going to check the JS code that you sent to understand, if everything is correct. And you shouldn't pay, if you want to test the service as we provide 40K requests/day for free.

GetBlock
  • 41
  • 2
  • Well sorry to say, but I am experiencing the same issue as the OP. Websocket to eth.getblock.io is working. bsc.getblock.io is not working. – Frank Jun 18 '21 at 20:06
  • I'm interested in testing the websockets API for BSC. I'd like to be able to know when the balance of a wallet on BSC has changed. Is this possible? – zero_cool Jun 25 '21 at 01:20
0

GetBlock currently (May 2021) doesn't support WebSocket provider.

From their pricing page:

Webhooks & WebSockets

Coming soon! We are constantly adding new features and upgrading the service


If HTTPS provider is sufficient to your use case (e.g. if you don't need to use the web3 subscriptions), you can use any provider that only supports HTTPS connection. Including GetBlock or the recommended providers stated in the BSC docs

Othwerwise, you'll need to use a different third-party provider that supports WebSockets or configure your own.

Petr Hejda
  • 40,554
  • 8
  • 72
  • 100
  • I`ve tried also with wss://apis.ankr.com/wss API but the result is same, i can`t connect to wss. My aim is to get pending Tx as fast as i can. I can do it over HttpProviders but it is quite slow protocol. Could you please recommend me any WSS provider for BSC? – mathew sada May 21 '21 at 18:27
  • Unfortunately I don't know any. BSC is still a very new network and the infrastructure around it is not yet much developed right now... If the speed is an important factor for you, I'd recommend setting up a BSC full node that will provide the WSS connection for your app. – Petr Hejda May 21 '21 at 18:32
  • yes it is an option to run the node, but the hardware i'm using is not enough to run it right now. Thank you for your quick response. – mathew sada May 21 '21 at 19:27
  • Have your tried QuickNode? Takes about 30 seconds to be up and running. 7 day free trial and then $9.00 per month... – Flood Techs Jul 03 '21 at 02:20
  • I looked at ANKR for bsc web sockets and there price is around $250.00 per month... – Flood Techs Jul 03 '21 at 02:24