JSON‑RPC Overview

Goa supports JSON‑RPC 2.0 over multiple transports:

  • HTTP (unary requests and responses)
  • HTTP Server‑Sent Events (SSE) for server‑initiated streaming
  • WebSocket for bidirectional streaming

Key properties:

  • Batch requests and notifications are supported where applicable.
  • The same JSON‑RPC HTTP route can serve SSE by content negotiation using the Accept header (application/json vs. text/event-stream).
  • JSON‑RPC WebSocket uses a single connection per service, shared by all methods.

Related concepts: see Transports for the matrix of allowed combinations within one service and per method.

Topics in this section

If you prefer a guided build, start with the tutorial: Basic JSON‑RPC Service.

Method names

On the wire, the JSON‑RPC method value is the DSL method name (for example: add). Each service has a single JSON‑RPC endpoint, so names are scoped to the service and do not need a service.method prefix.

Transport summary

TransportConnectionPatternsBatchingNotifications
HTTPRequest/responseNon‑streaming (unary)Yes (array body)Client → Yes
SSELong‑lived HTTP resp.Server streaming, mixed resultsNot applicableServer → Yes
WebSocketPersistent (full‑duplex)Client streaming, server streaming, bidirectionalNot typical (message‑oriented)Both directions

Notes:

  • SSE shares the same route as HTTP. The client selects SSE via Accept: text/event-stream and the method must declare a streaming result (or mixed results).
  • WebSocket is enabled by using GET on the JSON‑RPC endpoint. Non‑streaming methods are not supported over JSON‑RPC WebSocket.