Skip to content

Commit f88d8c4

Browse files
committed
Fix SignalR + MVC through Envoy
1 parent 8cc6808 commit f88d8c4

File tree

5 files changed

+35
-18
lines changed

5 files changed

+35
-18
lines changed

src/ApiGateways/Envoy/config/webshopping/envoy.yaml

+25-10
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,20 @@ static_resources:
4242
route:
4343
auto_host_rewrite: true
4444
prefix_rewrite: "/ordering-api/"
45-
cluster: ordering
45+
cluster: ordering
4646
- name: "o-long"
4747
match:
4848
prefix: "/ordering-api/"
4949
route:
5050
auto_host_rewrite: true
51-
cluster: ordering
51+
cluster: ordering
52+
- name: "h-long"
53+
match:
54+
prefix: "/hub/notificationhub"
55+
route:
56+
auto_host_rewrite: true
57+
cluster: signalr-hub
58+
timeout: 300s
5259
- name: "b-short"
5360
match:
5461
prefix: "/b/"
@@ -61,7 +68,7 @@ static_resources:
6168
prefix: "/basket-api/"
6269
route:
6370
auto_host_rewrite: true
64-
cluster: basket
71+
cluster: basket
6572
- name: "agg"
6673
match:
6774
prefix: "/"
@@ -70,7 +77,7 @@ static_resources:
7077
prefix_rewrite: "/"
7178
cluster: shoppingagg
7279
http_filters:
73-
- name: envoy.router
80+
- name: envoy.router
7481
access_log:
7582
- name: envoy.file_access_log
7683
filter:
@@ -80,15 +87,15 @@ static_resources:
8087
time: "%START_TIME%"
8188
protocol: "%PROTOCOL%"
8289
duration: "%DURATION%"
83-
request_method: "%REQ(:METHOD)%"
84-
request_host: "%REQ(HOST)%"
85-
path: "%REQ(X-ENVOY-ORIGINAL-PATH?:PATH)%"
90+
request_method: "%REQ(:METHOD)%"
91+
request_host: "%REQ(HOST)%"
92+
path: "%REQ(X-ENVOY-ORIGINAL-PATH?:PATH)%"
8693
response_flags: "%RESPONSE_FLAGS%"
8794
route_name: "%ROUTE_NAME%"
8895
upstream_host: "%UPSTREAM_HOST%"
8996
upstream_cluster: "%UPSTREAM_CLUSTER%"
9097
upstream_local_address: "%UPSTREAM_LOCAL_ADDRESS%"
91-
path: "/tmp/access.log"
98+
path: "/tmp/access.log"
9299
clusters:
93100
- name: shoppingagg
94101
connect_timeout: 0.25s
@@ -113,12 +120,20 @@ static_resources:
113120
hosts:
114121
- socket_address:
115122
address: basket-api
116-
port_value: 80
123+
port_value: 80
117124
- name: ordering
118125
connect_timeout: 0.25s
119126
type: strict_dns
120127
lb_policy: round_robin
121128
hosts:
122129
- socket_address:
123130
address: ordering-api
124-
port_value: 80
131+
port_value: 80
132+
- name: signalr-hub
133+
connect_timeout: 0.25s
134+
type: strict_dns
135+
lb_policy: round_robin
136+
hosts:
137+
- socket_address:
138+
address: ordering-signalrhub
139+
port_value: 80

src/Web/WebMVC/Views/Shared/_Layout.cshtml

+2
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,12 @@
102102
function stablishConnection(cb) {
103103
let connection = new signalR.HubConnectionBuilder()
104104
.withUrl('@settings.Value.SignalrHubUrl/hub/notificationhub', {
105+
transport: signalR.HttpTransportType.LongPolling,
105106
accessTokenFactory: () => {
106107
return "Authorization", getToken();
107108
}
108109
})
110+
.withAutomaticReconnect()
109111
.build();
110112
111113
connection.start().then(function () {

src/Web/WebMVC/bundleconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
{
1212
"outputFileName": "wwwroot/js/site.js",
1313
"inputFiles": [
14-
"wwwroot/lib/@aspnet/signalr/dist/browser/signalr.js",
14+
"wwwroot/lib/@microsoft/signalr/dist/browser/signalr.js",
1515
"wwwroot/lib/toastr/toastr.min.js"
1616
],
1717
// Optionally specify minification options

src/Web/WebMVC/libman.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
{
1010
"provider": "unpkg",
1111
"library": "[email protected]",
12+
"destination": "wwwroot/lib/bootstrap/",
1213
"files": [
1314
"dist/css/bootstrap.css",
1415
"dist/css/bootstrap.css.map",
1516
"dist/css/bootstrap.min.css",
1617
"dist/css/bootstrap.min.css.map",
1718
"dist/js/bootstrap.js",
1819
"dist/js/bootstrap.min.js"
19-
],
20-
"destination": "wwwroot/lib/bootstrap/"
20+
]
2121
},
2222
{
2323
"library": "[email protected]",
@@ -37,12 +37,12 @@
3737
},
3838
{
3939
"provider": "unpkg",
40-
"library": "@aspnet/[email protected]",
41-
"files": [
40+
"library": "@microsoft/[email protected]",
41+
"destination": "wwwroot/lib/@microsoft/signalr/",
42+
"files": [
4243
"dist/browser/signalr.js",
4344
"dist/browser/signalr.min.js"
44-
],
45-
"destination": "wwwroot/lib/@aspnet/signalr/"
45+
]
4646
}
4747
]
4848
}

src/docker-compose.override.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ services:
360360
- PurchaseUrl=http://webshoppingapigw
361361
- IdentityUrl=http://10.0.75.1:5105
362362
- MarketingUrl=http://webmarketingapigw
363-
- SignalrHubUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5112
363+
- SignalrHubUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5202
364364
- IdentityUrlHC=http://identity-api/hc
365365
- UseCustomizationData=True
366366
- ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY}

0 commit comments

Comments
 (0)