SFS :java.lang.IllegalStateException

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

nik0990
Posts: 76
Joined: 23 Dec 2016, 10:48
Location: India

SFS :java.lang.IllegalStateException

Postby nik0990 » 08 Sep 2021, 07:13

Hi,

I send a lot commands but never get this kind of issue.

07 Sep 2021 | 13:24:55,616 | WARN | https-jsse-nio-8893-exec-7 | tomcat.websocket.SFS2XWSService | | Error writing to client: { Id: 7790, Type: WEBSOCKET, Logged: Yes, IP: 162.158.46.118:58564 }
java.lang.InterruptedException
at java.util.concurrent.locks.AbstractQueuedSynchronizer.tryAcquireSharedNanos(AbstractQueuedSynchronizer.java:1326)
at java.util.concurrent.Semaphore.tryAcquire(Semaphore.java:409)
at org.apache.tomcat.util.net.SocketWrapperBase.vectoredOperation(SocketWrapperBase.java:1451)
at org.apache.tomcat.util.net.SocketWrapperBase.write(SocketWrapperBase.java:1403)
at org.apache.tomcat.util.net.SocketWrapperBase.write(SocketWrapperBase.java:1374)
at org.apache.tomcat.websocket.server.WsRemoteEndpointImplServer.doWrite(WsRemoteEndpointImplServer.java:91)
at org.apache.tomcat.websocket.WsRemoteEndpointImplBase.writeMessagePart(WsRemoteEndpointImplBase.java:494)
at org.apache.tomcat.websocket.WsRemoteEndpointImplBase.startMessage(WsRemoteEndpointImplBase.java:381)
at org.apache.tomcat.websocket.WsRemoteEndpointImplBase.sendBytesByCompletion(WsRemoteEndpointImplBase.java:151)
at org.apache.tomcat.websocket.WsRemoteEndpointAsync.sendBinary(WsRemoteEndpointAsync.java:65)
at sfs2x.ws.tomcat.websocket.SFS2XWSService._write(SFS2XWSService.java:344)
at sfs2x.ws.tomcat.websocket.SFS2XWSService.write(SFS2XWSService.java:337)
at com.smartfoxserver.bitswarm.websocket.tomcat.WebSocketBinaryProtocolCodec.onPacketWrite(WebSocketBinaryProtocolCodec.java:121)
at com.smartfoxserver.bitswarm.core.BitSwarmEngine.writeToWebSocket(BitSwarmEngine.java:425)
at com.smartfoxserver.bitswarm.core.BitSwarmEngine.write(BitSwarmEngine.java:406)
at com.smartfoxserver.bitswarm.io.Response.write(Response.java:70)


followed BY below exception

07 Sep 2021 | 13:25:00,616 | WARN | pool-1-thread-3 | websocket.tomcat.WebSocketBinaryProtocolCodec | | java.lang.IllegalStateException:
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Exception: java.lang.IllegalStateException
Message: The remote endpoint was in state [BINARY_FULL_WRITING] which is an invalid state for called method
Description: Error during websocket packet write
+--- --- ---+
Stack Trace:
+--- --- ---+
org.apache.tomcat.websocket.WsRemoteEndpointImplBase$StateMachine.checkState(WsRemoteEndpointImplBase.java:1229)
org.apache.tomcat.websocket.WsRemoteEndpointImplBase$StateMachine.binaryStart(WsRemoteEndpointImplBase.java:1181)
org.apache.tomcat.websocket.WsRemoteEndpointImplBase.sendBytesByCompletion(WsRemoteEndpointImplBase.java:150)
org.apache.tomcat.websocket.WsRemoteEndpointAsync.sendBinary(WsRemoteEndpointAsync.java:65)
sfs2x.ws.tomcat.websocket.SFS2XWSService._write(SFS2XWSService.java:344)
sfs2x.ws.tomcat.websocket.SFS2XWSService.write(SFS2XWSService.java:337)



Command values {"useConverter":false,"type":["MTT_BREAK","Tournament will go on break for 5 minutes."],"roomName":"XXXXXXXXXX"}

due to this Client facing disconnection
User avatar
Lapo
Site Admin
Posts: 23025
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SFS :java.lang.IllegalStateException

Postby Lapo » 08 Sep 2021, 08:05

What version of SFS2X are you running?
If possible I'd recommend updating to 2.17.3 which fixes a potential issue related to this.
https://www.smartfoxserver.com/download/#p=updates

Also, please, check that this error is not happening when sending data to clients in a Scheduled Task. If it is this is likely caused by canceling the task abruptly instead of letting it finish it's current job.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
nik0990
Posts: 76
Joined: 23 Dec 2016, 10:48
Location: India

Re: SFS :java.lang.IllegalStateException

Postby nik0990 » 08 Sep 2021, 09:12

What version of SFS2X are you running?


I am using SFS 2.17.0

Also, please, check that this error is not happening when sending data to clients in a Scheduled Task. If it is this is likely caused by canceling the task abruptly instead of letting it finish it's current job.


How can I verify this? This is problem in one command only

Note:

It is not coming for all users in the room.
User avatar
Lapo
Site Admin
Posts: 23025
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SFS :java.lang.IllegalStateException

Postby Lapo » 08 Sep 2021, 14:58

Hi,
How can I verify this? This is problem in one command only

I am not sure what you mean. What command are you referring to?

As regards the Scheduled Task I was mentioning. If you are using them, make sure that when you call the Task.cancel() method you don't use the this version of the command:

Code: Select all

Task.cancel(true);

Here the extra boolean tells the Task to shutdown immediately regardless of what the current thread executing it is doing. This can cause the kind of error you have reported. If you have similar code in your Extension just remove the true parameter, so that the Task has a chance to complete its job before being removed from the Scheduler.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
ersindemir
Posts: 30
Joined: 30 Apr 2016, 07:23
Location: Turkey

Re: SFS :java.lang.IllegalStateException

Postby ersindemir » 08 Nov 2021, 14:09

Hi;
I updated smartfox server 2.17.3 from 2.12.0. Same problem was occurred on WebGL clients (not Android or IOS). I fixed problem with Lapo answer. If you use "Task.cancel(true);" on your game or zone extension codes , change it to "Task.cancel(false);"

Thank you for answer , Lapo.
User avatar
Lapo
Site Admin
Posts: 23025
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SFS :java.lang.IllegalStateException

Postby Lapo » 08 Nov 2021, 14:10

ersindemir wrote:Thank you for answer , Lapo.

Sure, no problem :)
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Stevenor, Thomasea and 58 guests