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
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.
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.
© 2022 - 2024 — McMap. All rights reserved.