File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -196,6 +196,41 @@ Example output:
196
196
```
197
197
> NOTE: Please see ` docs ` configuration entry explained above.
198
198
199
+ ### WebSockets support
200
+ WebSockets proxying is supported since ` v3.1.0 ` :
201
+ - WebSockets middlewares are not supported.
202
+ - WebSocketRoute configuration definition:
203
+ ``` ts
204
+ interface WebSocketRoute {
205
+ proxyType: ' websocket' ;
206
+ // https://github.com/faye/faye-websocket-node#initialization-options
207
+ proxyConfig? : {};
208
+ prefix: string ;
209
+ target: string ;
210
+ // https://github.com/faye/faye-websocket-node#subprotocol-negotiation
211
+ subProtocols? : [];
212
+ hooks? : WebSocketHooks ;
213
+ }
214
+
215
+ interface WebSocketHooks {
216
+ onOpen? : (ws : any , searchParams : URLSearchParams ) => Promise <void >;
217
+ }
218
+ ```
219
+ - The ` / ` route prefix is considered the default route.
220
+
221
+ #### Configuration example:
222
+ ``` js
223
+ gateway ({
224
+ routes: [{
225
+ // ... other HTTP or WebSocket routes
226
+ }, {
227
+ proxyType: ' websocket' ,
228
+ prefix: ' /echo' ,
229
+ target: ' ws://ws.ifelse.io'
230
+ }]
231
+ }).start (PORT )
232
+ ```
233
+
199
234
## Timeouts and Unavailability
200
235
We can restrict requests timeouts globally or at service level using the ` timeout ` configuration.
201
236
You can’t perform that action at this time.
0 commit comments