mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 06:48:16 +08:00
Feature/websockets (#273)
* #212 - hacked websockets proxy together * faffing around * #212 hacking away :( * #212 websockets proxy middleware working * #212 map when for webockets working * #212 some test refactor * #212 temp commit * #212 websockets proxy working, tests passing...need to do some tidying and write docs * #212 more code coverage * #212 docs for websockets * #212 updated readme * #212 tidying up after websockets refactoring * #212 tidying up after websockets refactoring * #212 tidying up after websockets refactoring * stuck a warning in about logging levels into docs!
This commit is contained in:
68
docs/features/websockets.rst
Normal file
68
docs/features/websockets.rst
Normal file
@ -0,0 +1,68 @@
|
||||
Websockets
|
||||
==========
|
||||
|
||||
Ocelot supports proxying websockets with some extra bits. This functionality was requested in `Issue 212 <https://github.com/ThreeMammals/Ocelot/issues/212>`_.
|
||||
|
||||
In order to get websocket proxying working with Ocelot you need to do the following.
|
||||
|
||||
In your Configure method you need to tell your application to use WebSockets.
|
||||
|
||||
.. code-block:: csharp
|
||||
|
||||
Configure(app =>
|
||||
{
|
||||
app.UseWebSockets();
|
||||
app.UseOcelot().Wait();
|
||||
})
|
||||
|
||||
Then in your configuration.json add the following to proxy a ReRoute using websockets.
|
||||
|
||||
.. code-block:: json
|
||||
|
||||
{
|
||||
"DownstreamPathTemplate": "/ws",
|
||||
"UpstreamPathTemplate": "/",
|
||||
"DownstreamScheme": "ws",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "localhost",
|
||||
"Port": 5001
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
With this configuration set Ocelot will match any websocket traffic that comes in on / and proxy it to localhost:5001/ws. To make this clearer
|
||||
Ocelot will receive messages from the upstream client, proxy these to the downstream service, receive messages from the downstream service and
|
||||
proxy these to the upstream client.
|
||||
|
||||
Supported
|
||||
^^^^^^^^^
|
||||
|
||||
1. Load Balancer
|
||||
2. Routing
|
||||
3. Service Discovery
|
||||
|
||||
This means that you can set up your downstream services running websockets and either have multiple DownstreamHostAndPorts in your ReRoute
|
||||
config or hook your ReRoute into a service discovery provider and then load balance requests...Which I think is pretty cool :)
|
||||
|
||||
Not Supported
|
||||
^^^^^^^^^^^^^
|
||||
|
||||
Unfortunately a lot of Ocelot's features are non websocket specific such as header and http client stuff. I've listed what won't work below.
|
||||
|
||||
1. Tracing
|
||||
2. RequestId
|
||||
3. Request Aggregation
|
||||
4. Rate Limiting
|
||||
5. Quality of Service
|
||||
6. Middleware Injection
|
||||
7. Header Transformation
|
||||
8. Delegating Handlers
|
||||
9. Claims Transformation
|
||||
10. Caching
|
||||
11. Authentication - If anyone requests it we might be able to do something with basic authentication.
|
||||
12. Authorisation
|
||||
|
||||
I'm not 100% sure what will happen with this feature when it get's into the wild so please make sure you test thoroughly!
|
||||
|
||||
|
Reference in New Issue
Block a user