首页 新闻 搜索 专区 学院

Ocelot动态路由如何配置运行signalR连接?

0
悬赏园豆:60 [待解决问题]

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
}
}
}
···

被遗忘者灬的主页 被遗忘者灬 | 初学一级 | 园豆:132
提问于:2019-02-21 09:34
< >
分享
所有回答(2)
0

根据官方文档 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" ]
   }
]
蝌蝌 | 园豆:158 (初学一级) | 2019-02-22 10:45

嗯,多谢,这个是看到了的。使用动态路由的时候不能配置多个DownstreamScheme 。如果同时要使用http 和 ws就不行。

支持(0) 反对(0) 被遗忘者灬 | 园豆:132 (初学一级) | 2019-03-02 15:22
0

现在阶段的版本好像是不支持在动态路由中同时配置http和ws.

被遗忘者灬 | 园豆:132 (初学一级) | 2019-03-02 15:24
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册