llamanodes / web3-proxy

Fast loadbalancing and caching proxy for Ethereum or chains with similar JSON-RPC methods
https://llamanodes.com
GNU General Public License v3.0
154 stars 34 forks source link

WebSocket provider doesn't support batched requests #230

Closed ghost closed 1 year ago

ghost commented 1 year ago

I have sent something like

socket.send(JSON.stringify([
            {
              jsonrpc: '2.0',
              method: 'eth_chainId',
              params: [],
              id: 1
            },
            {
              jsonrpc: '2.0',
              method: 'eth_getBlockByNumber',
              params: ['latest', false],
              id: 2
            }
          ]));

And got rejected with the errror

{
  jsonrpc: '2.0',
  id: null,
  error: {
    code: 400,
    message: 'de/serialization error!',
    data: 'invalid type: map, expected a string at line 1 column 1'
  }
}

While it is a normal batch request and shouldn't be rejected.

ghost commented 1 year ago

Ah I think most websocket providers doesn't support batch requests so closing

BlinkyStitt commented 1 year ago

It is something we've thought about adding. It just makes the parsing a bit more complicated.

Also, since you have a websocket open, its just as easy to send a bunch of individual requests