Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tyrus send partial message more than buffer size will cause exception in catalina OutputBuffer. In original glassfish 4.1 (not nightly build) works fine. Tyrus 1.10 with original glassfish 4.1 works fine too. #327

Closed
HighTower1991 opened this issue Jun 10, 2015 · 9 comments · Fixed by #387

Comments

@HighTower1991
Copy link

java.lang.IllegalStateException: Cannot set WriteListener for non-async or non-upgrade request
at org.apache.catalina.connector.OutputBuffer.setWriteListener(OutputBuffer.java:536)
at org.apache.catalina.connector.CoyoteOutputStream.setWriteListener(CoyoteOutputStream.java:223)
at org.glassfish.tyrus.servlet.TyrusServletWriter.write(TyrusServletWriter.java:140)
at org.glassfish.tyrus.core.ProtocolHandler.write(ProtocolHandler.java:486)
at org.glassfish.tyrus.core.ProtocolHandler.send(ProtocolHandler.java:274)
at org.glassfish.tyrus.core.ProtocolHandler.send(ProtocolHandler.java:269)
at org.glassfish.tyrus.core.ProtocolHandler.stream(ProtocolHandler.java:402)
at org.glassfish.tyrus.core.TyrusWebSocket.sendBinary(TyrusWebSocket.java:406)
at org.glassfish.tyrus.core.TyrusWebSocket.sendBinary(TyrusWebSocket.java:392)
at org.glassfish.tyrus.core.TyrusRemoteEndpoint$Basic.sendBinary(TyrusRemoteEndpoint.java:141)

@HighTower1991 HighTower1991 changed the title Tyrus send partial message more than buffer size will cause exception in catalina OutputBuffer. In original glassfish 4.1 (not nightly build) woks fine. Tyrus 1.10 with original glassfish 4.1 works fine too. Tyrus send partial message more than buffer size will cause exception in catalina OutputBuffer. In original glassfish 4.1 (not nightly build) works fine. Tyrus 1.10 with original glassfish 4.1 works fine too. Jun 10, 2015
@smillidge smillidge added upstream bug PR: TESTS REQUIRED PR Requires Tests to be merged labels Jun 10, 2015
@HighTower1991
Copy link
Author

Test case may be simple. Even if send not patial message but more big than buffer size from server endpoint then client session close with buffer overflow and on server will be the same exception. I use annotated endpoint on client and server and send response message to client by session.getAsyncEndpoint().sendBinary and the same exception occur.

@peteral
Copy link

peteral commented Jun 25, 2015

I am getting the same exception, however from my investigations it looks to be happening when sending an object message through Async when the Session is currently occupied delivering a previous telegram to client (OutputStream still busy).

Stack trace:

Caused by: java.lang.IllegalStateException: Cannot set WriteListener for non-async or non-upgrade request
    at org.apache.catalina.connector.OutputBuffer.setWriteListener(OutputBuffer.java:536)
    at org.apache.catalina.connector.CoyoteOutputStream.setWriteListener(CoyoteOutputStream.java:223)
    at org.glassfish.tyrus.servlet.TyrusServletWriter.write(TyrusServletWriter.java:140)
    at org.glassfish.tyrus.core.ProtocolHandler.write(ProtocolHandler.java:486)
    at org.glassfish.tyrus.core.ProtocolHandler.send(ProtocolHandler.java:274)
    at org.glassfish.tyrus.core.ProtocolHandler.send(ProtocolHandler.java:269)
    at org.glassfish.tyrus.core.ProtocolHandler.send(ProtocolHandler.java:320)
    at org.glassfish.tyrus.core.TyrusWebSocket.sendText(TyrusWebSocket.java:306)
    at org.glassfish.tyrus.core.TyrusRemoteEndpoint.sendSyncObject(TyrusRemoteEndpoint.java:400)
    at org.glassfish.tyrus.core.TyrusRemoteEndpoint$Async.sendAsync(TyrusRemoteEndpoint.java:295)
    at org.glassfish.tyrus.core.TyrusRemoteEndpoint$Async.sendObject(TyrusRemoteEndpoint.java:256)
    at eisenmann.logic.vstore.hmi.server.SessionRepositoryBean.sendObject(SessionRepositoryBean.java:212)

Tried to work around the problem by using Basic and Locks in EJB Thread pool to only use a Session when idle, but sometimes tyrus keeps waiting for a future forewer and this blocks the whole EJB thread pool and completely blocks the application server:

__ejb-thread-pool47" thread-id: 393 thread-state: WAITING Waiting on lock: java.util.concurrent.CountDownLatch$Sync@1b5a87c2
     at: sun.misc.Unsafe.park(Native Method)
     at: java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
     at: java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:836)
     at: java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:997)
     at: java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1304)
     at: java.util.concurrent.CountDownLatch.await(CountDownLatch.java:231)
     at: org.glassfish.tyrus.core.TyrusFuture.get(TyrusFuture.java:77)
     at: org.glassfish.tyrus.core.TyrusRemoteEndpoint$Basic.sendObject(TyrusRemoteEndpoint.java:177)
     at: eisenmann.logic.vstore.hmi.server.SessionRepositoryBean.sendObject(SessionRepositoryBean.java:212)

Not sure how to reproduce the problem for I only get it in production environment. Was not able to simulate it yet in the stress tests. Probably because they only run via loopback and don't cover the diversity of the real production environment. Will try to make a stress test including real network communication, maybe this helps.

We have following configuration:

  • HMI system visualising production plants, JEE7 / HTML5 + GWT
  • Clients Chrome and Firefox around 100
  • Observed machines causing transactions in the system around 250
  • There is a relatively high amount of data transferred via the websocket (current status of the installation, client registers to "variables" and gets informed when they change)
  • also having problems with glassfish in this area although they manifest a little differenty, that's why I started evaluating payara (commercial support also looks interesting after oracle gave it up for glassfish)
  • currently I have the most stable environment in this area with glassfish 4.0 but this version has tons of other issues

Not sure what to try next, any idea any1?

@HighTower1991
Copy link
Author

Make simple test server and client: https://github.com/HighTower1991/PayaraTest

@smillidge
Copy link
Contributor

Thanks that will help a lot

@smillidge smillidge added try to reproduce and removed PR: TESTS REQUIRED PR Requires Tests to be merged labels Jul 27, 2015
@smillidge
Copy link
Contributor

Hi I tried to reproduce this with your test case on the latest Payara 4.1.153 but I do not get an error. I get;

On the server

[#|2015-08-08T21:31:11.481+0100|INFO|Payara 4.1||_ThreadID=102;_ThreadName=Thread-8;_TimeMillis=1439065871481;_LevelValue=800;|
  Hello from client: java.nio.HeapByteBuffer[pos=0 lim=0 cap=0]|#]

On the client

Hello from server: java.nio.HeapByteBuffer[pos=0 lim=5000000 cap=5000000]

@smillidge
Copy link
Contributor

Hi I can't reproduce on Payara 4.1.152.1 either. Is there anything special that needs to be done?

@smillidge
Copy link
Contributor

I've reproduced this by putting a loop in the client to send multiple messages.

smillidge pushed a commit to smillidge/Payara that referenced this issue Aug 8, 2015
@smillidge smillidge added this to the Payara Server 4.1.154 milestone Aug 8, 2015
@smillidge
Copy link
Contributor

@peteral I suspect you are only seeing this with object messages as they exceed a size threshold. Hopefully the referenced pull request will fix your issue as well.

@peteral
Copy link

peteral commented Aug 9, 2015

@smillidge it's possible, we do use object messages and the content is quite big. I am on vacation now but will test the pull request when I am back in office (end of August).

Thanks a lot guys...

smillidge added a commit that referenced this issue Aug 9, 2015
smillidge pushed a commit to smillidge/Payara that referenced this issue Sep 14, 2015
Pandrex247 pushed a commit to Pandrex247/Payara that referenced this issue May 4, 2021
[Enterprise] FISH-1014 Variables (ENV=...) in @DatasourceDefinition not applied to 'className'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants