mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-22 05:32:51 +08:00

* #296 renamed configuration.json to ocelot.json in preparation * removed things we dont need for tests * another file we dont need * removed some async we dont need * refactoring to consolidate configuration code * removed another pointless abstraction * #296 started writing merge code * #296 coming up with ideas for this config merging * #296 still hacking this idea around * #296 will now do a crappy merge on the configuration * #296 change so tests pass on windows
69 lines
2.1 KiB
ReStructuredText
69 lines
2.1 KiB
ReStructuredText
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 ocelot.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!
|
|
|
|
|