Websocket issues - hanging server


#1

So I’m running the websockets extension. After a few days, it starts giving the following error message and the server processing of requests slows down, eventually requiring a restart of the server. Any thoughts on what could be going on?

Version	Lucee 5.2.2.4-SNAPSHOT
Version Name	Velvet
Release date	May 8, 2017
ColdFusion® compatibility version	2016.0.03.300357
Configuration File	/usr/local/apache-tomcat-8.0.28/webapps/lucee-5.1.0.34/WEB-INF/lucee-server/context/lucee-server.xml
OS	Mac OS X (10.12.5) 64bit
Remote IP	0:0:0:0:0:0:0:1
Host Name	localhost
Servlet Container	Apache Tomcat/8.0.28
Java	1.8.0_51 (Oracle Corporation) 64bit
Architecture	64bit
"ERROR","Thread-5667","05/18/2017","17:30:10","",";The remote endpoint was in state [TEXT_FULL_WRITING] which is an invalid state for called method;lucee.runtime.exp.NativeException: The remote endpoint was in state [TEXT_FULL_WRITING] which is an invalid state for called method
        at org.apache.tomcat.websocket.WsRemoteEndpointImplBase$StateMachine.checkState(WsRemoteEndpointImplBase.java:1148)
        at org.apache.tomcat.websocket.WsRemoteEndpointImplBase$StateMachine.textStart(WsRemoteEndpointImplBase.java:1111)
        at org.apache.tomcat.websocket.WsRemoteEndpointImplBase.sendString(WsRemoteEndpointImplBase.java:192)
        at org.apache.tomcat.websocket.WsRemoteEndpointBasic.sendText(WsRemoteEndpointBasic.java:37)
        at net.twentyonesolutions.lucee.websocket.WebSocket.sendText(WebSocket.java:391)
        at net.twentyonesolutions.lucee.websocket.connections.ConnectionManager.broadcast(ConnectionManager.java:175)
        at net.twentyonesolutions.lucee.websocket.connections.ConnectionManager.call(ConnectionManager.java:398)
        at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:758)
        at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1701)
        at server.mixins.websocketsmanager_cfc$cf.udfCall(/orrms/server/mixins/WebSocketsManager.cfc:19)
        at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:106)
        at lucee.runtime.type.UDFImpl._call(UDFImpl.java:338)
        at lucee.runtime.type.UDFImpl.call(UDFImpl.java:225)
        at lucee.runtime.ComponentImpl._call(ComponentImpl.java:697)
        at lucee.runtime.ComponentImpl._call(ComponentImpl.java:580)
        at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1918)
        at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:758)
        at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1701)
        at pagingmember_cfc$cf.udfCall(/resources/pagingMember.cfc:71)
        at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:106)
        at lucee.runtime.type.UDFImpl._call(UDFImpl.java:338)
        at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:211)
        at lucee.runtime.ComponentImpl._call(ComponentImpl.java:698)
        at lucee.runtime.ComponentImpl._call(ComponentImpl.java:580)
        at lucee.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1931)
        at lucee.runtime.tag.Invoke.doComponent(Invoke.java:221)
        at lucee.runtime.tag.Invoke.doEndTag(Invoke.java:194)
        at taffy.core.api_cfc$cf.udfCall1(/orrmsapiv1/taffy/core/api.cfc:337)
        at taffy.core.api_cfc$cf.udfCall(/orrmsapiv1/taffy/core/api.cfc)
        at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:106)
        at lucee.runtime.type.UDFImpl._call(UDFImpl.java:338)
        at lucee.runtime.type.UDFImpl.call(UDFImpl.java:225)
        at lucee.runtime.ComponentImpl._call(ComponentImpl.java:697)
        at lucee.runtime.ComponentImpl._call(ComponentImpl.java:580)
        at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1918)
        at lucee.runtime.listener.ModernAppListener.call(ModernAppListener.java:420)
        at lucee.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:222)
        at lucee.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:43)
        at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2408)
        at lucee.runtime.PageContextImpl._execute(PageContextImpl.java:2398)
        at lucee.runtime.PageContextImpl.executeCFML(PageContextImpl.java:2366)
        at lucee.runtime.engine.Request.run(Request.java:34)
Caused by: java.lang.IllegalStateException: The remote endpoint was in state [TEXT_FULL_WRITING] which is an invalid state for called method
        ... 42 more

#2

Please open a ticket at https://github.com/isapir/lucee-websocket/issues and add as many details as possible, including some code snippets of how you use the extension.

I will look at it as soon as I can.


#3

Just as a follow up: I solved this problem by using an exclusive lock around connectionManager.broadcast(…). Should such a lock be within the WS extension itself so it doesn’t try to write to the socket when it’s already writing?


#4

possibly. I saw somewhere that this is a synchronization issue, but I asked you to open a ticket and you didn’t do that so I didn’t pursue looking into it since you were the only one who reported it.


#5

Added as https://github.com/isapir/lucee-websocket/issues/6


#6

FYI: This issue has been fixed in version 2.0 of the extension, but the setup of the extension has changed because of some other required changes, so please see README.md at https://github.com/isapir/lucee-websocket