Commit 29c35eadee022a485ce7c7c3e622905972bce082

Authored by Igor Kulikov
1 parent 5a87bbe7

WebSocket error handling

... ... @@ -201,8 +201,12 @@ public class TbWebSocketHandler extends TextWebSocketHandler implements Telemetr
201 201 if (isSending) {
202 202 try {
203 203 msgQueue.add(msg);
204   - } catch (RuntimeException e){
205   - log.trace("[{}] Session closed due to queue error", session.getId(), e);
  204 + } catch (RuntimeException e) {
  205 + if (log.isTraceEnabled()) {
  206 + log.trace("[{}][{}] Session closed due to queue error", sessionRef.getSecurityCtx().getTenantId(), session.getId(), e);
  207 + } else {
  208 + log.info("[{}][{}] Session closed due to queue error", sessionRef.getSecurityCtx().getTenantId(), session.getId());
  209 + }
206 210 try {
207 211 close(sessionRef, CloseStatus.POLICY_VIOLATION.withReason("Max pending updates limit reached!"));
208 212 } catch (IOException ioe) {
... ... @@ -221,7 +225,7 @@ public class TbWebSocketHandler extends TextWebSocketHandler implements Telemetr
221 225 } catch (Exception e) {
222 226 log.trace("[{}] Failed to send msg", session.getId(), e);
223 227 try {
224   - close(this.sessionRef, CloseStatus.SERVER_ERROR);
  228 + close(this.sessionRef, CloseStatus.SESSION_NOT_RELIABLE);
225 229 } catch (IOException ioe) {
226 230 log.trace("[{}] Session transport error", session.getId(), ioe);
227 231 }
... ... @@ -233,7 +237,7 @@ public class TbWebSocketHandler extends TextWebSocketHandler implements Telemetr
233 237 if (!result.isOK()) {
234 238 log.trace("[{}] Failed to send msg", session.getId(), result.getException());
235 239 try {
236   - close(this.sessionRef, CloseStatus.SERVER_ERROR);
  240 + close(this.sessionRef, CloseStatus.SESSION_NOT_RELIABLE);
237 241 } catch (IOException ioe) {
238 242 log.trace("[{}] Session transport error", session.getId(), ioe);
239 243 }
... ...