Any takers to tackle this issue?

-----Original Message-----
From: Serge Perepel [mailto:se...@american-data.com] 
Sent: Friday, January 26, 2018 2:33 PM
To: Tomcat Users List
Subject: RE: Suspected memory leak of 
org.apache.coyote.AbstractProtocol$ConnectionHandler object while using 
Websocket

-----Original Message-----
From: Mark Thomas [mailto:ma...@apache.org]

>This is likely to get looked at faster if you provide code that other people 
>can run that will reproduce the issue you are seeing rather than expecting 
>someone else to construct the test case for you.

Here is how you can reproduce it:

Server websocket:

package ad.ecs.websocket;

import java.io.IOException;

import javax.websocket.CloseReason;
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;

@ServerEndpoint(value = "/asyncMsg")
public class TestWebsocket {
    @OnOpen
    public void open(Session session) throws IOException{
        session.getBasicRemote().sendText("Connection Established");
    }

    @OnMessage
    public String login(String sessionID, Session session) {
//        you can do this instead of exception and it will still leak memory
//        try {
//            session.close(new CloseReason(CloseCodes.GOING_AWAY, "Clearing 
session"));
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
        throw new IllegalArgumentException("Testing Leak");
    }

    @OnClose
    public void close(Session session, CloseReason reason) {
    }

    @OnError
    public void error(Session session, Throwable error) {
        error.printStackTrace();
    }

}

Here is the front end html:

<!DOCTYPE html>
<head>
    <script type="text/javascript" src="app.js"></script> </head> <body>
    <div>
        <button onclick="test()">
            LEAK
        </button>
    </div>
</body>
</html>

Here is js file:

    var webSocket = null;

    function test() {
        console.log("test button clicked");
        openSocket();
    }

    function openSocket() {
        console.log("open webSocket");
        webSocket = new WebSocket("ws://" + window.location.host + 
"/memoryleak/asyncMsg");

        webSocket.onopen = function(event){
            console.log("webSocket open");
            webSocket.send('test');
        };

        webSocket.onmessage = function(event){
            console.log("webSocket onMessage", event);
        };

        webSocket.onclose = function(event){
            webSocket = null;
            console.log("webSocket connection closed", event);
            openSocket();
        };
    }

    function closeSocket(){
        console.log("close webSocket");
        if (webSocket)
            webSocket.close();
    }

You need to run it on multiple clients if you want it leak fast. We did it with 
8 clients and it leaked 3GB with in like 10 min.

Thank you
[http://www.american-data.com/images/AmericanDataLogoRoundedEmailSignature.png]<www.american-data.com>

Serge Perepel
Software Developer | American Data
p. 608.643.8022 | tf. 800.464.9942 | f. 608.643.2314 
se...@american-data.com<mailto:se...@american-data.com> | www.american-data.com


[Follow us on 
Facebook]<https://www.facebook.com/pages/American-Data/100445186666233>   
[Follow us on LinkedIn] <https://www.linkedin.com/company/american-data>    
[Follow us on Twitter] <https://twitter.com/AmericanDataECS>   [Follow us on 
Twitter] <https://www.youtube.com/channel/UCiKfcsunZXWIYHf_2oE708A>


Notice: This message is the property of 1984 Systems, Inc. (DBA) American Data 
and contains information that may be confidential and/or privileged. If you are 
not the intended recipient, you should not use, disclose or take any action 
based on the message. If you have received this transmission in error, please 
immediately contact the sender by return e-mail and delete this e-mail, and any 
attachments, from any computer.

[ECS 10 Conversion]<http://www.american-data.com/viewer>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to