Commit 302cc5985e0a718ae463c59372bcb38f40fe8381
Merge branch 'master' of github.com:thingsboard/thingsboard
Showing
6 changed files
with
36 additions
and
11 deletions
... | ... | @@ -99,7 +99,7 @@ public class DefaultActorService implements ActorService { |
99 | 99 | |
100 | 100 | @PostConstruct |
101 | 101 | public void initActorSystem() { |
102 | - log.info("Initializing Actor system. {}", actorContext.getRuleChainService()); | |
102 | + log.info("Initializing Actor system."); | |
103 | 103 | actorContext.setActorService(this); |
104 | 104 | system = ActorSystem.create(ACTOR_SYSTEM_NAME, actorContext.getConfig()); |
105 | 105 | actorContext.setActorSystem(system); | ... | ... |
... | ... | @@ -263,7 +263,7 @@ public class TbWebSocketHandler extends TextWebSocketHandler implements Telemetr |
263 | 263 | if (regularUserSessions.size() < maxSessionsPerRegularUser) { |
264 | 264 | regularUserSessions.add(sessionId); |
265 | 265 | } else { |
266 | - log.info("[{}][{}][{}] Failed to start session. Max user sessions limit reached" | |
266 | + log.info("[{}][{}][{}] Failed to start session. Max regular user sessions limit reached" | |
267 | 267 | , sessionRef.getSecurityCtx().getTenantId(), sessionRef.getSecurityCtx().getId(), sessionId); |
268 | 268 | session.close(CloseStatus.POLICY_VIOLATION.withReason("Max regular user sessions limit reached")); |
269 | 269 | return false; |
... | ... | @@ -276,7 +276,7 @@ public class TbWebSocketHandler extends TextWebSocketHandler implements Telemetr |
276 | 276 | if (publicUserSessions.size() < maxSessionsPerPublicUser) { |
277 | 277 | publicUserSessions.add(sessionId); |
278 | 278 | } else { |
279 | - log.info("[{}][{}][{}] Failed to start session. Max user sessions limit reached" | |
279 | + log.info("[{}][{}][{}] Failed to start session. Max public user sessions limit reached" | |
280 | 280 | , sessionRef.getSecurityCtx().getTenantId(), sessionRef.getSecurityCtx().getId(), sessionId); |
281 | 281 | session.close(CloseStatus.POLICY_VIOLATION.withReason("Max public user sessions limit reached")); |
282 | 282 | return false; | ... | ... |
... | ... | @@ -266,7 +266,7 @@ public class DefaultTelemetryWebSocketService implements TelemetryWebSocketServi |
266 | 266 | } else if (customerSessions.size() < maxSubscriptionsPerCustomer) { |
267 | 267 | customerSessions.add(subId); |
268 | 268 | } else { |
269 | - log.info("[{}][{}][{}] Failed to start subscription. Max customer sessions limit reached" | |
269 | + log.info("[{}][{}][{}] Failed to start subscription. Max customer subscriptions limit reached" | |
270 | 270 | , sessionRef.getSecurityCtx().getTenantId(), sessionRef.getSecurityCtx().getId(), subId); |
271 | 271 | msgEndpoint.close(sessionRef, CloseStatus.POLICY_VIOLATION.withReason("Max customer subscriptions limit reached")); |
272 | 272 | return false; |
... | ... | @@ -279,7 +279,7 @@ public class DefaultTelemetryWebSocketService implements TelemetryWebSocketServi |
279 | 279 | if (regularUserSessions.size() < maxSubscriptionsPerRegularUser) { |
280 | 280 | regularUserSessions.add(subId); |
281 | 281 | } else { |
282 | - log.info("[{}][{}][{}] Failed to start subscription. Max user sessions limit reached" | |
282 | + log.info("[{}][{}][{}] Failed to start subscription. Max regular user subscriptions limit reached" | |
283 | 283 | , sessionRef.getSecurityCtx().getTenantId(), sessionRef.getSecurityCtx().getId(), subId); |
284 | 284 | msgEndpoint.close(sessionRef, CloseStatus.POLICY_VIOLATION.withReason("Max regular user subscriptions limit reached")); |
285 | 285 | return false; |
... | ... | @@ -292,7 +292,7 @@ public class DefaultTelemetryWebSocketService implements TelemetryWebSocketServi |
292 | 292 | if (publicUserSessions.size() < maxSubscriptionsPerPublicUser) { |
293 | 293 | publicUserSessions.add(subId); |
294 | 294 | } else { |
295 | - log.info("[{}][{}][{}] Failed to start subscription. Max user sessions limit reached" | |
295 | + log.info("[{}][{}][{}] Failed to start subscription. Max public user subscriptions limit reached" | |
296 | 296 | , sessionRef.getSecurityCtx().getTenantId(), sessionRef.getSecurityCtx().getId(), subId); |
297 | 297 | msgEndpoint.close(sessionRef, CloseStatus.POLICY_VIOLATION.withReason("Max public user subscriptions limit reached")); |
298 | 298 | return false; | ... | ... |
... | ... | @@ -26,7 +26,7 @@ const WS_IDLE_TIMEOUT = 90000; |
26 | 26 | const MAX_PUBLISH_COMMANDS = 10; |
27 | 27 | |
28 | 28 | /*@ngInject*/ |
29 | -function TelemetryWebsocketService($rootScope, $websocket, $timeout, $window, types, userService) { | |
29 | +function TelemetryWebsocketService($rootScope, $websocket, $timeout, $window, $mdUtil, toast, types, userService) { | |
30 | 30 | |
31 | 31 | var isOpening = false, |
32 | 32 | isOpened = false, |
... | ... | @@ -111,7 +111,10 @@ function TelemetryWebsocketService($rootScope, $websocket, $timeout, $window, ty |
111 | 111 | } |
112 | 112 | } |
113 | 113 | |
114 | - function onError (/*message*/) { | |
114 | + function onError (errorEvent) { | |
115 | + if (errorEvent) { | |
116 | + showWsError(0, errorEvent); | |
117 | + } | |
115 | 118 | isOpening = false; |
116 | 119 | } |
117 | 120 | |
... | ... | @@ -137,7 +140,10 @@ function TelemetryWebsocketService($rootScope, $websocket, $timeout, $window, ty |
137 | 140 | } |
138 | 141 | } |
139 | 142 | |
140 | - function onClose () { | |
143 | + function onClose (closeEvent) { | |
144 | + if (closeEvent && closeEvent.code > 1000 && closeEvent.code !== 1006) { | |
145 | + showWsError(closeEvent.code, closeEvent.reason); | |
146 | + } | |
141 | 147 | isOpening = false; |
142 | 148 | isOpened = false; |
143 | 149 | if (isActive) { |
... | ... | @@ -162,7 +168,9 @@ function TelemetryWebsocketService($rootScope, $websocket, $timeout, $window, ty |
162 | 168 | function onMessage (message) { |
163 | 169 | if (message.data) { |
164 | 170 | var data = angular.fromJson(message.data); |
165 | - if (data.subscriptionId) { | |
171 | + if (data.errorCode) { | |
172 | + showWsError(data.errorCode, data.errorMsg); | |
173 | + } else if (data.subscriptionId) { | |
166 | 174 | var subscriber = subscribers[data.subscriptionId]; |
167 | 175 | if (subscriber && data) { |
168 | 176 | var keys = fetchKeys(data.subscriptionId); |
... | ... | @@ -182,6 +190,18 @@ function TelemetryWebsocketService($rootScope, $websocket, $timeout, $window, ty |
182 | 190 | checkToClose(); |
183 | 191 | } |
184 | 192 | |
193 | + function showWsError(errorCode, errorMsg) { | |
194 | + var message = 'WebSocket Error: '; | |
195 | + if (errorMsg) { | |
196 | + message += errorMsg; | |
197 | + } else { | |
198 | + message += "error code - " + errorCode + "."; | |
199 | + } | |
200 | + $mdUtil.nextTick(function () { | |
201 | + toast.showError(message); | |
202 | + }); | |
203 | + } | |
204 | + | |
185 | 205 | function fetchKeys(subscriptionId) { |
186 | 206 | var command = commands[subscriptionId]; |
187 | 207 | if (command && command.keys && command.keys.length > 0) { | ... | ... |
... | ... | @@ -23,7 +23,9 @@ export default angular.module('thingsboard.types', []) |
23 | 23 | permissionDenied: 20, |
24 | 24 | invalidArguments: 30, |
25 | 25 | badRequestParams: 31, |
26 | - itemNotFound: 32 | |
26 | + itemNotFound: 32, | |
27 | + tooManyRequests: 33, | |
28 | + tooManyUpdates: 34 | |
27 | 29 | }, |
28 | 30 | entryPoints: { |
29 | 31 | login: "/api/auth/login", | ... | ... |
... | ... | @@ -16,18 +16,21 @@ |
16 | 16 | |
17 | 17 | md-toast.tb-info-toast .md-toast-content { |
18 | 18 | height: 100%; |
19 | + max-height: 100%; | |
19 | 20 | padding: 18px; |
20 | 21 | font-size: 18px; |
21 | 22 | } |
22 | 23 | |
23 | 24 | md-toast.tb-success-toast .md-toast-content { |
24 | 25 | height: 100%; |
26 | + max-height: 100%; | |
25 | 27 | font-size: 18px !important; |
26 | 28 | background-color: #008000; |
27 | 29 | } |
28 | 30 | |
29 | 31 | md-toast.tb-error-toast .md-toast-content { |
30 | 32 | height: 100%; |
33 | + max-height: 100%; | |
31 | 34 | font-size: 18px !important; |
32 | 35 | background-color: #800000; |
33 | 36 | } | ... | ... |