Open Source API Gateway
7. Transports and Clients

webSocket

Version

Lets clients upgrade a connection to the WebSocket protocol (RFC 6455) and relays it between client and backend. Without this plugin, upgrade requests are rejected. The upgrade request passes the flow like any other request, so plugins before webSocket, e.g. for authentication, apply to it.

Without frame interceptors, the bytes of the connection are relayed unchanged. With frame interceptors, every message passes them as one complete frame: fragmented messages are joined, and no WebSocket extension such as permessage-deflate is negotiated. If a frame interceptor fails, both peers are sent a close frame with status 1011 (internal error).

 webSocket:
   [ url: <url> ]
   [ maxMessageSize: <bytes> ]
   [ flow:
       - wsLog: {} | wsStompReassembler: ... | wsInterceptor: ...
       ... ]
 

Example Configuration

api:
port: 2000
flow:
- webSocket:
flow:
- wsLog: {}
target:
host: localhost
port: 8080
api:
   port: 2000
   flow:
     - webSocket:
         flow:
           - wsLog: {}
   target:
     host: localhost
     port: 8080

Syntax

webSocket:
'$ref': <string>
flow:
- <flow>
maxMessageSize: <int>
url: <string>
webSocket:
  '$ref': <string>
  flow:
    - <flow>
  maxMessageSize: <int>
  url: <string>

Attributes

NameRequiredDefaultDescriptionExamples
$reffalse-Reference a component defined under components.-
maxMessageSizefalse16777216Maximum size of a message in bytes, in either direction, when frame interceptors are configured. Each message is held in memory while it passes them. A peer that sends a larger message is sent a close frame with status 1009 (message too big), and the connection is closed. Without frame interceptors, there is no limit.1048576
urlfalse-Backend for WebSocket connections, instead of the API's target. Its host and port select the server, its path and query replace those of the upgrade request. Other requests still go to the target.http://localhost:61614/

Child Structure

ElementCardinalityDescription
flow0..*Frame interceptors. Messages from the client pass them in the given order, messages from the server in reverse order.

Can be used in