This is an automated email from the ASF dual-hosted git repository.

pdallig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/zeppelin.git


The following commit(s) were added to refs/heads/master by this push:
     new a985c56ab4 [ZEPPELIN-1480] rework websocket sending to prevent partial 
frontend hangup (#4800)
a985c56ab4 is described below

commit a985c56ab4db33145fa16f0670ad4db783100bc8
Author: johannesschillinger-dm 
<136588873+johannesschillinger...@users.noreply.github.com>
AuthorDate: Tue Sep 17 13:12:03 2024 +0200

    [ZEPPELIN-1480] rework websocket sending to prevent partial frontend hangup 
(#4800)
    
    * [ZEPPELIN-1480] synchronize websocket sync to prevent issues with blocked 
websockets due to multithreading
    
    * [ZEPPELIN-1480] use async call to websocket for sending
    
    also add debug logging to the class
    
    * [ZEPPELIN-1480] improve error logging
    
    * [ZEPPELIN-1480] re-add license text
    
    * [ZEPPELIN-1480] remove debug logging from getters
    
    * [ZEPPELIN-1480] fix indentation
---
 .../main/java/org/apache/zeppelin/socket/NotebookSocket.java | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git 
a/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookSocket.java 
b/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookSocket.java
index 58c41cddc3..6050c54b87 100644
--- 
a/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookSocket.java
+++ 
b/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookSocket.java
@@ -18,6 +18,8 @@ package org.apache.zeppelin.socket;
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.zeppelin.utils.ServerUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.util.Map;
@@ -28,6 +30,8 @@ import javax.websocket.Session;
  * Notebook websocket.
  */
 public class NotebookSocket {
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(NotebookSocket.class);
+
   private Session session;
   private Map<String, Object> headers;
   private String user;
@@ -36,6 +40,7 @@ public class NotebookSocket {
     this.session = session;
     this.headers = headers;
     this.user = StringUtils.EMPTY;
+    LOGGER.debug("NotebookSocket created for session: {}", session.getId());
   }
 
   public String getHeader(String key) {
@@ -43,7 +48,11 @@ public class NotebookSocket {
   }
 
   public void send(String serializeMessage) throws IOException {
-    session.getBasicRemote().sendText(serializeMessage);
+    session.getAsyncRemote().sendText(serializeMessage, result -> {
+      if (result.getException() != null) {
+        LOGGER.error("Failed to send async message for User {} in Session {}: 
{}", this.user, this.session.getId(), result.getException());
+      }
+    });
   }
 
   public String getUser() {
@@ -51,6 +60,7 @@ public class NotebookSocket {
   }
 
   public void setUser(String user) {
+    LOGGER.debug("Setting user: {}", user);
     this.user = user;
   }
 

Reply via email to