Browse Source

added validation for max value of wsQueueMessagesPerSession

pull/8241/head
dashevchenko 4 years ago
parent
commit
939c00c299
  1. 9
      application/src/main/java/org/thingsboard/server/controller/plugin/TbWebSocketHandler.java
  2. 2
      application/src/main/resources/thingsboard.yml
  3. 2
      ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.html
  4. 2
      ui-ngx/src/app/shared/models/tenant.model.ts
  5. 2
      ui-ngx/src/assets/locale/locale.constant-en_US.json

9
application/src/main/java/org/thingsboard/server/controller/plugin/TbWebSocketHandler.java

@ -84,8 +84,8 @@ public class TbWebSocketHandler extends TextWebSocketHandler implements WebSocke
private long sendTimeout;
@Value("${server.ws.ping_timeout:30000}")
private long pingTimeout;
@Value("${server.ws.default_queue_messages_per_session:1000}")
private int wsQueueMessagesPerSession;
@Value("${server.ws.max_queue_messages_per_session:1000}")
private int wsMaxQueueMessagesPerSession;
private final ConcurrentMap<String, WebSocketSessionRef> blacklistedSessions = new ConcurrentHashMap<>();
private final ConcurrentMap<String, TbRateLimits> perSessionUpdateLimits = new ConcurrentHashMap<>();
@ -146,8 +146,9 @@ public class TbWebSocketHandler extends TextWebSocketHandler implements WebSocke
}
var tenantProfileConfiguration = getTenantProfileConfiguration(sessionRef);
internalSessionMap.put(internalSessionId, new SessionMetaData(session, sessionRef,
tenantProfileConfiguration != null && tenantProfileConfiguration.getWsMsgQueueLimitPerSession() > 0 ?
tenantProfileConfiguration.getWsMsgQueueLimitPerSession() : wsQueueMessagesPerSession));
tenantProfileConfiguration != null && tenantProfileConfiguration.getWsMsgQueueLimitPerSession() > 0 &&
tenantProfileConfiguration.getWsMsgQueueLimitPerSession() < wsMaxQueueMessagesPerSession ?
tenantProfileConfiguration.getWsMsgQueueLimitPerSession() : wsMaxQueueMessagesPerSession));
externalSessionMap.put(externalSessionId, internalSessionId);
processInWebSocketService(sessionRef, SessionEvent.onEstablished());

2
application/src/main/resources/thingsboard.yml

@ -65,7 +65,7 @@ server:
max_per_user: "${TB_SERVER_WS_DYNAMIC_PAGE_LINK_MAX_PER_USER:10}"
max_entities_per_data_subscription: "${TB_SERVER_WS_MAX_ENTITIES_PER_DATA_SUBSCRIPTION:10000}"
max_entities_per_alarm_subscription: "${TB_SERVER_WS_MAX_ENTITIES_PER_ALARM_SUBSCRIPTION:10000}"
default_queue_messages_per_session: "${TB_SERVER_WS_DEFAULT_QUEUE_MESSAGES_PER_SESSION:1000}"
max_queue_messages_per_session: "${TB_SERVER_WS_DEFAULT_QUEUE_MESSAGES_PER_SESSION:1000}"
rest:
server_side_rpc:
# Minimum value of the server side RPC timeout. May override value provided in the REST API call.

2
ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.html

@ -411,7 +411,7 @@
{{ 'tenant-profile.too-small-value-one' | translate}}
</mat-error>
<mat-hint>
{{ 'tenant-profile.value-will-be-dropped-to-default' | translate}}
{{ 'tenant-profile.queue-size-is-limited-by-system-configuration' | translate}}
</mat-hint>
</mat-form-field>
<div fxFlex></div>

2
ui-ngx/src/app/shared/models/tenant.model.ts

@ -111,7 +111,7 @@ export function createTenantProfileConfiguration(type: TenantProfileType): Tenan
maxWsSessionsPerCustomer: 0,
maxWsSessionsPerRegularUser: 0,
maxWsSessionsPerPublicUser: 0,
wsMsgQueueLimitPerSession: 1000,
wsMsgQueueLimitPerSession: 0,
maxWsSubscriptionsPerTenant: 0,
maxWsSubscriptionsPerCustomer: 0,
maxWsSubscriptionsPerRegularUser: 0,

2
ui-ngx/src/assets/locale/locale.constant-en_US.json

@ -3576,7 +3576,7 @@
"incorrect-pattern-for-rate-limits": "The format is comma separated pairs of capacity and period (in seconds) with a colon between, e.g. 100:1,2000:60",
"too-small-value-zero": "The value must be bigger than 0",
"too-small-value-one": "The value must be bigger than 1",
"value-will-be-dropped-to-default": "0 value will be dropped to default",
"queue-size-is-limited-by-system-configuration": "The size of the queue is also limited by the system configuration.",
"cassandra-tenant-limits-configuration": "Cassandra query for tenant",
"ws-limit-max-sessions-per-tenant": "Sessions per tenant maximum number",
"ws-limit-max-sessions-per-customer": "Sessions per customer maximum number",

Loading…
Cancel
Save