Ocelot动态路由和Consul时,Signalr无法成功连接。如何配置多个DownstreamScheme同时运行http和ws访问呢?
···
{
"ReRoutes": [],
"Aggregates": [],
"GlobalConfiguration": {
"BaseUrl": null,
"RequestIdKey": null,
"ServiceDiscoveryProvider": {
"Host": "192.168.2.88",
"Port": 8500,
"Type": "Consul",
"Token": null,
"ConfigurationKey": null
},
"RateLimitOptions": {
"ClientIdHeader": "ClientId",
"QuotaExceededMessage": null,
"RateLimitCounterPrefix": "ocelot",
"DisableRateLimitHeaders": false,
"HttpStatusCode": 9999
},
//"QoSOptions": {
// "ExceptionsAllowedBeforeBreaking": 0,
// "DurationOfBreak": 0,
// "TimeoutValue": 0
//},
"UpstreamHeaderTransform": {
"X-Forwarded-For": "{RemoteIpAddress}"
},
"LoadBalancerOptions": {
"Type": "RoundRobin", //负载均衡规则
"Key": null,
"Expiry": 0
},
"DownstreamScheme": "http",
"HttpHandlerOptions": {
"AllowAutoRedirect": false,
"UseCookieContainer": false,
"UseTracing": false
}
}
}
···
根据官方文档 https://ocelot.readthedocs.io/en/latest/features/websockets.html
需要现在 Startup 中启用 websockets
Configure(app =>
{
app.UseWebSockets();
app.UseOcelot().Wait();
})
然后再配置
{
"ReRoutes": [
{
"DownstreamPathTemplate": "/{catchAll}",
"DownstreamScheme": "ws",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 50000
}
],
"UpstreamPathTemplate": "/gateway/{catchAll}",
"UpstreamHttpMethod": [ "GET", "POST", "PUT", "DELETE", "OPTIONS" ]
}
]
嗯,多谢,这个是看到了的。使用动态路由的时候不能配置多个DownstreamScheme 。如果同时要使用http 和 ws就不行。
现在阶段的版本好像是不支持在动态路由中同时配置http和ws.