gagliardetto / solana-go

Go SDK library and RPC client for the Solana Blockchain
Apache License 2.0
929 stars 264 forks source link

WSS method blockSubscribe throws "Invalid/Unspported params for blockSubscribe." #171

Closed slyofzero closed 8 months ago

slyofzero commented 9 months ago

I am following the example given here about the WSS method of blockSubscribe, to get data about the news blocks and the transactions in them.

Below is my implementation in JS -

socket.addEventListener("open", () => {
  const subscribeMessage = {
    jsonrpc: "2.0",
    id: "1",
    method: "blockSubscribe",
    params: [{ filter: "all" }],
  };

  console.log("WSS stream started");
  const messageString = JSON.stringify(subscribeMessage);
  socket.send(messageString);
});

Response I get -

  [Symbol(kType)]: 'message',
  [Symbol(kData)]: '{"id":"1","jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid/Unspported params for blockSubscribe."}}'

I am using the alchemy mainnet RPC for creating this WSS connection.

gagliardetto commented 8 months ago
  const subscribeMessage = {
    jsonrpc: "2.0",
    id: "1",
    method: "blockSubscribe",
    params: ["all"],
  };
gagliardetto commented 8 months ago

Closing as this seems not related to solana-go.