[prev in list] [next in list] [prev in thread] [next in thread]
List: tomcat-user
Subject: =?UTF-8?Q?Tomcat_throws_IllegalStateException_=E2=80=9CThe_remote_en?= =?UTF-8?Q?dpoint_was_in_state
From: Farzad Panahi <farzad.panahi () gmail ! com>
Date: 2015-10-28 2:15:02
Message-ID: CACueeY2=-1Oqr0yW6kQL=NVyMZeYQBRzZR7_1TyYiEn2DtCeKg () mail ! gmail ! com
[Download RAW message or body]
Hi,
I am using tomcat 8.0.23 to terminate my websocket connections. I have
the following code to take care of the incoming messages:
@OnMessage
public void onMsg(Session session, byte[] request) {
executorService.execute(() ->
session.getAsyncRemote().sendBinary(
ByteBuffer.wrap(getResponse(session,
request)), result -> {
if (!result.isOK()) {
LOGGER.catching(result.getException());
}
}
));
}
But I get the following exception:
Exception in thread "pool-6-thread-10160"
java.lang.IllegalStateException: The remote endpoint was in state
[BINARY_FULL_WRITING] which is an invalid state for called method
at org.apache.tomcat.websocket.WsRemoteEndpointImplBase$StateMachine.ch=
eckState(WsRemoteEndpointImplBase.java:1148)
at org.apache.tomcat.websocket.WsRemoteEndpointImplBase$StateMachine.bi=
naryStart(WsRemoteEndpointImplBase.java:1101)
at org.apache.tomcat.websocket.WsRemoteEndpointImplBase.sendBytesByComp=
letion(WsRemoteEndpointImplBase.java:152)
at org.apache.tomcat.websocket.WsRemoteEndpointAsync.sendBinary(WsRemot=
eEndpointAsync.java:65)
From what I understand from java doc, RemoteEndpoint.Async.sendBinary
should not throw IllegalStateException:
> sendBinary void sendBinary(ByteBuffer data, SendHandler handler)
> Throws: IllegalArgumentException - if either the data or the handler are =
null.
It is also good to note that RemoEndpoint.Basic (not
RemoteEndpoint.Async) has the following paragraph in java doc:
> If the websocket connection underlying this RemoteEndpoint is busy sendin=
g a message when a call is made to send another one, for example if two th=
reads attempt to call a send method concurrently, or if a developer attemp=
ts to send a new message while in the middle of sending an existing one, th=
e send method called while the connection is already busy may throw an Ille=
galStateException.
Is this expected behaviour from tomcat or a possible implementation bug?
Cheers
Farzad
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic