This article applies to:
- Binance Smart Chain
Difference between HTTP and WebSocket protocols
HTTP is unidirectional while WebSocket is bidirectional.
In client-server communication, each HTTP request from the client establishes a new connection and gets closed on receiving a response from the server.
In client-server communication, a WebSocket connection is made once and reused until either the server or the client terminates the connection.
HTTP vs WebSocket for EVM node connections
The general recommendation is to use WebSocket rather than HTTP when connecting to an EVM node. WebSocket has the advantage of the connection reusability and the keep-alive mechanism.
- 60 seconds timeout for idle connection.
- Can be used for calls that have very short response time such as eth_call, eth_sendRawTransaction.
- 3600 seconds (1 hour) timeout for idle connection.
- Should be used for calls like eth_getLogs that have a response rate longer than 60 seconds.
- Maximum number of connections is 250.
See also WebSocket connection to an EVM node.