'When to use RPC over WebSocket?
I have 2 components which need to communicate with each other in bidirectional way. For now I have 2 approaches, one is setting up RPC server in both side to establish the 2-way communication. Another is using websocket. Could anyone help me to compare the pros and cons of RPC and WebSocket ? Thanks
Solution 1:[1]
WebSocket is a message-based transport, while RPC is a communication pattern. If you want routed RPCs over WebSocket, then take a look at the WAMP protocol (http://wamp-proto.org). This avoids having to set up a server/opening a port on each component, and allows them to communicate from behind NATs.
Full disclosure: I am deeply involved in the WAMP ecosystem, but the protocol is open, as are most of the implementations.
Solution 2:[2]
As gzost says, RPC is a type of protocol. Websockets are a transport mechanism.
RPEP is another protocol for RPC and event-based communication that has a javascript implementation for node.js and the browser. Its much simpler than WAMP (WAMP's spec is about 6 times larger) and its more flexible as a result.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | gzost |
Solution 2 | Billy Tetrud |