问题
We’re using PrimeFaces 4.0 (socket) and atmosphere 2.0.3 for server side push in our J2E application.
The issue with application it doesn’t close socket after closing browser or logout from the application. Hence application produce a socket in CLOSE_WAIT status and ultimately it create too many open connections(1024) and it throw below error. Most of the connections on this port on CLOSE_WAIT status.
JBWEB003008: Maximum number of threads (1024) created for connector with address /0.0.0.0 and port XXX.
code snippet for socket in JSP
<p:socket id="s" channel="#{xxx.eventChannel}"
onMessage="modelEventHandler.handleModelEvent" widgetVar="xxxSocket" transport="sse" onClose=""/>
I’ve tried to close this by calling java script function on click of logout button but it doesn’t work.
function logOut() {
PF(xxxSocket).disconnect();
}
回答1:
You can try PF('chat-socket').disconnect();
来源:https://stackoverflow.com/questions/43628306/how-to-close-primefaces-socket-connection