Skip to content

Commit 496df7f

Browse files
committed
adding websocket docs
1 parent 24933e0 commit 496df7f

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,41 @@ Example output:
196196
```
197197
> NOTE: Please see `docs` configuration entry explained above.
198198
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+
199234
## Timeouts and Unavailability
200235
We can restrict requests timeouts globally or at service level using the `timeout` configuration.
201236

0 commit comments

Comments
 (0)