Hi everyone!

I encountered a problem with embedded tomcat 8.5.29 (part of spring boot
1.5).
The number of websocket connections that are stored in a variable
"*connections"
(look below) *is increasing indefinitely.

package org.apache.coyote;

public abstract class AbstractProtocol<S> implements ProtocolHandler,
MBeanRegistration {

...

protected static class ConnectionHandler<S> implements
AbstractEndpoint.Handler<S> {

...

private final Map<S,Processor> connections = new
ConcurrentHashMap<>(); // <-- The number of websocket connections that
are stored in a variable is increasing indefinitely

...

}

...

}

As a result websocket connections consume too much memory.
I see the reason for the fact that the socket remains in
the SocketState.UPGRADED state even after closing the websocket. Although
expected SocketState.CLOSED.
Log:
2019-02-18 13:22:12.741 DEBUG
[test-service,e248a18fb0789f6c,e248a18fb0789f6c,true] 1 ---
[nio-8080-exec-9] org.apache.tomcat.websocket.WsSession    : *Closing
WebSocket session [{1}]*
2019-02-18 13:22:12.742 DEBUG
[test-service,e248a18fb0789f6c,e248a18fb0789f6c,true] 1 ---
[nio-8080-exec-9] o.a.tomcat.util.net.SocketWrapperBase    : Socket:
[org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper@723dc871
:org.apache.tomcat.util.net.NioChannel@7587eeb9:java.nio.channels.SocketChannel[connected
local=attachment-8559c85989-w9k5r/10.244.4.175:8080
remote=/10.244.2.25:44986]], Read from buffer: [0]
2019-02-18 13:22:12.742 DEBUG
[test-service,e248a18fb0789f6c,e248a18fb0789f6c,true] 1 ---
[nio-8080-exec-9] o.a.c.h.u.UpgradeProcessorInternal       : Socket:
[org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper@723dc871
:org.apache.tomcat.util.net.NioChannel@7587eeb9:java.nio.channels.SocketChannel[connected
local=attachment-8559c85989-w9k5r/10.244.4.175:8080
remote=/10.244.2.25:44986]], Status in: [OPEN_READ], State out: [UPGRADED]

Full log by request below (I disguised private data as ###):
2019-02-18 13:22:12.731 DEBUG [test-service,,,] 1 --- [nio-8080-exec-9]
o.a.tomcat.util.net.SocketWrapperBase    : Socket:
[org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper@723dc871
:org.apache.tomcat.util.net.NioChannel@7587eeb9:java.nio.channels.SocketChannel[connected
local=/10.244.4.175:8080 remote=/10.244.2.25:44986]], Read from buffer: [0]
2019-02-18 13:22:12.731 DEBUG [test-service,,,] 1 --- [nio-8080-exec-9]
o.a.coyote.http11.Http11InputBuffer      : Received [GET ### HTTP/1.1
X-Real-IP: 10.244.0.0
X-Forwarded-For: 10.244.0.0,10.244.6.23
Authorization: ###
Origin: http://ptdbo2kbm251lv:32175
Referer: http://ptdbo2lre202v:8081/DigestProcessor/
User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)
Accept-Encoding: gzip, deflate
Accept: */*
Cookie: ###
X-Forwarded-Proto: http
X-Forwarded-Port: 80
X-Forwarded-Host: ###
upgrade: websocket
connection: upgrade
sec-websocket-key: ###
host: ptdbo2kbm251lv
sec-websocket-origin: ###
sec-websocket-version: 13

]
2019-02-18 13:22:12.731 DEBUG [test-service,,,] 1 --- [nio-8080-exec-9]
o.a.t.util.http.Rfc6265CookieProcessor   : Cookies: Parsing b[]: ###
2019-02-18 13:22:12.733 DEBUG
[test-service,e248a18fb0789f6c,e248a18fb0789f6c,true] 1 ---
[nio-8080-exec-9] org.apache.tomcat.util.http.Parameters   : Set encoding
to UTF-8
2019-02-18 13:22:12.734 DEBUG
[test-service,e248a18fb0789f6c,e248a18fb0789f6c,true] 1 ---
[nio-8080-exec-9] o.apache.coyote.http11.Http11Processor   : Socket:
[org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper@723dc871
:org.apache.tomcat.util.net.NioChannel@7587eeb9:java.nio.channels.SocketChannel[connected
local=attachment-8559c85989-w9k5r/10.244.4.175:8080
remote=/10.244.2.25:44986]], Status in: [OPEN_READ], State out: [UPGRADING]
2019-02-18 13:22:12.734 DEBUG
[test-service,e248a18fb0789f6c,e248a18fb0789f6c,true] 1 ---
[nio-8080-exec-9] org.apache.tomcat.websocket.WsSession    : Created
WebSocket session [15f]
2019-02-18 13:22:12.734 DEBUG
[test-service,e248a18fb0789f6c,e248a18fb0789f6c,true] 1 ---
[nio-8080-exec-9] o.a.t.websocket.server.WsFrameServer     :
wsFrameServer.onDataAvailable
2019-02-18 13:22:12.735 DEBUG
[attachment,e248a18fb0789f6c,e248a18fb0789f6c,true] 1 --- [nio-8080-exec-9]
o.a.tomcat.util.net.SocketWrapperBase    : Socket:
[org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper@723dc871
:org.apache.tomcat.util.net.NioChannel@7587eeb9:java.nio.channels.SocketChannel[connected
local=attachment-8559c85989-w9k5r/10.244.4.175:8080
remote=/10.244.2.25:44986]], Read from buffer: [0]
2019-02-18 13:22:12.735 DEBUG
[test-service,e248a18fb0789f6c,e248a18fb0789f6c,true] 1 ---
[nio-8080-exec-9] o.a.t.websocket.server.WsFrameServer     : Read [71]
bytes into input buffer ready for processing
2019-02-18 13:22:12.735 DEBUG
[test-service,e248a18fb0789f6c,e248a18fb0789f6c,true] 1 ---
[nio-8080-exec-9] o.a.t.websocket.server.WsFrameServer     : WebSocket
frame received. fin [true], rsv [0], OpCode [1], payload length [65]
2019-02-18 13:22:12.741 DEBUG
[test-service,e248a18fb0789f6c,e248a18fb0789f6c,true] 1 ---
[nio-8080-exec-9] org.apache.tomcat.websocket.WsSession    : Closing
WebSocket session [{1}]
2019-02-18 13:22:12.742 DEBUG
[test-service,e248a18fb0789f6c,e248a18fb0789f6c,true] 1 ---
[nio-8080-exec-9] o.a.tomcat.util.net.SocketWrapperBase    : Socket:
[org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper@723dc871
:org.apache.tomcat.util.net.NioChannel@7587eeb9:java.nio.channels.SocketChannel[connected
local=attachment-8559c85989-w9k5r/10.244.4.175:8080
remote=/10.244.2.25:44986]], Read from buffer: [0]
2019-02-18 13:22:12.742 DEBUG
[test-service,e248a18fb0789f6c,e248a18fb0789f6c,true] 1 ---
[nio-8080-exec-9] o.a.c.h.u.UpgradeProcessorInternal       : Socket:
[org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper@723dc871
:org.apache.tomcat.util.net.NioChannel@7587eeb9:java.nio.channels.SocketChannel[connected
local=attachment-8559c85989-w9k5r/10.244.4.175:8080
remote=/10.244.2.25:44986]], Status in: [OPEN_READ], State out: [UPGRADED]

Added attachment file with a demonstration of a large amount of memory
consumed. Does anyone mean how to fix this?
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to