ASF Bugzilla – Attachment 31055 Details for
Bug 55799
[websocket] Stability issues when concurrently sending large messages
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Test case (modifications to the Chat example)
Chat_TestCase.patch (text/plain), 3.14 KB, created by
Konstantin Preißer
on 2013-11-20 00:01:34 UTC
(
hide
)
Description:
Test case (modifications to the Chat example)
Filename:
MIME Type:
Creator:
Konstantin Preißer
Created:
2013-11-20 00:01:34 UTC
Size:
3.14 KB
patch
obsolete
>Index: webapps/examples/WEB-INF/classes/websocket/chat/ChatAnnotation.java >=================================================================== >--- webapps/examples/WEB-INF/classes/websocket/chat/ChatAnnotation.java (revision 1543570) >+++ webapps/examples/WEB-INF/classes/websocket/chat/ChatAnnotation.java (working copy) >@@ -22,12 +22,17 @@ > import java.util.concurrent.atomic.AtomicInteger; > > import javax.websocket.OnClose; >+import javax.websocket.OnError; > import javax.websocket.OnMessage; > import javax.websocket.OnOpen; > import javax.websocket.Session; > import javax.websocket.server.ServerEndpoint; > >+import org.apache.juli.logging.Log; >+import org.apache.juli.logging.LogFactory; >+ > import util.HTMLFilter; >+import websocket.drawboard.DrawboardEndpoint; > > @ServerEndpoint(value = "/websocket/chat") > public class ChatAnnotation { >@@ -39,6 +44,9 @@ > > private final String nickname; > private Session session; >+ >+ private static final Log log = >+ LogFactory.getLog(ChatAnnotation.class); > > public ChatAnnotation() { > nickname = GUEST_PREFIX + connectionIds.getAndIncrement(); >@@ -68,8 +76,18 @@ > // Never trust the client > String filteredMessage = String.format("%s: %s", > nickname, HTMLFilter.filter(message.toString())); >+ >+ for (int i = 0; i < 8; i++) { >+ filteredMessage = filteredMessage + filteredMessage; >+ } > broadcast(filteredMessage); > } >+ >+ @OnError >+ public void onError(Throwable t) throws Throwable { >+ log.error("Chat Error: " + t.toString(), t); >+ >+ } > > > private static void broadcast(String msg) { >@@ -76,16 +94,8 @@ > for (ChatAnnotation client : connections) { > try { > client.session.getBasicRemote().sendText(msg); >- } catch (IOException e) { >- connections.remove(client); >- try { >- client.session.close(); >- } catch (IOException e1) { >- // Ignore >- } >- String message = String.format("* %s %s", >- client.nickname, "has been disconnected."); >- broadcast(message); >+ } catch (Exception e) { >+ > } > } > } >Index: webapps/examples/websocket/chat.xhtml >=================================================================== >--- webapps/examples/websocket/chat.xhtml (revision 1543570) >+++ webapps/examples/websocket/chat.xhtml (working copy) >@@ -74,7 +74,7 @@ > }; > > Chat.socket.onmessage = function (message) { >- Console.log(message.data); >+ //Console.log("Received: " + message.data.length); > }; > }); > >@@ -117,6 +117,12 @@ > for (var i = 0; i < noscripts.length; i++) { > noscripts[i].parentNode.removeChild(noscripts[i]); > } >+ >+ window.setInterval(function() { >+ if (Chat.socket.readyState == 1) { >+ Chat.socket.send("klajsdlaskjdlajsdhouhwo8ahsdoajsodjaso doasijdoiajs odij asoijd oöasijo ödiasj öodisajoöasiöjd asoaidjasoidjaklsdjlask jsd"); >+ } >+ }, 50); > }, false); > > ]]></script>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 55799
:
31055
|
31056
|
31057
|
31060
|
31078