Skip to content

WebSocket server should offer the same features as the HTTP server #4991

@Neurone

Description

@Neurone

Problem

When developers or apps connect to the WebSocket port of the Relay, they expect to leverage at least the same functionalities offered by the HTTP port, in addition to the WS specific ones (i.e. subscription).

At the moment, that expectation is not fulfilled and developers/applications can discover later in the process that a specific method is not supported by the WS connection. Because the application cannot use a dynamic failover to the HTTP version (subscription should become polling, etc.) this forces the applications to always use the HTTP server if they want to be sure everything will work.

This is an example with the eth_feeHistory method:

echo '{"method":"eth_feeHistory","params":["0x4", "latest", [25, 75]],"id":1,"jsonrpc":"2.0"}' | websocat wss://testnet.hashio.io/ws

{"error":{"code":-32601,"message":"[Request ID: 1056199a-6e67-4b36-bbe9-7b4cfb48a7ad] Method eth_feeHistory not found"},"jsonrpc":"2.0","id":1}


➜  curl https://testnet.hashio.io/api -X POST -H "Content-Type: application/json" --data '{"method":"eth_feeHistory","params":["0x4", "latest", [25, 75]],"id":1,"jsonrpc":"2.0"}'

{"result":{"baseFeePerGas":["0xe680992c00","0xe680992c00","0xe680992c00","0xe680992c00","0xe680992c00"],"gasUsedRatio":[0.5,0.5,0.5,0.5],"oldestBlock":"0x1da5d11","reward":[["0x0","0x0"],["0x0","0x0"],["0x0","0x0"],["0x0","0x0"]]},"jsonrpc":"2.0","id":1}

Solution

  • The WebSocket connection should be just another way to access the same functionalities offered by the HTTP server.
  • All methods provided by the Relay and not strictly related to the HTTP/WS protocol (i.e. subscribe, unsubscribe) should be offered on both HTTP and WS connections.

Alternatives

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions