When to use RPC over WebSocket?
Asked Answered
G

2

7

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

Gardner answered 13/6, 2017 at 0:45 Comment(1)
WebSocket can do RPC. This is like asking "Is strawberry better than chocolate?"Interphone
A
7

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.

Assess answered 13/6, 2017 at 11:32 Comment(0)
I
0

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.

Impropriate answered 15/4, 2022 at 20:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.