Commit 29c35eadee022a485ce7c7c3e622905972bce082

Authored by Igor Kulikov
1 parent 5a87bbe7

WebSocket error handling

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