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

[Glassfish] [HTTPS] Сonnection breaks every few seconds #744

Closed
freeflyer opened this issue Nov 26, 2012 · 33 comments
Closed

[Glassfish] [HTTPS] Сonnection breaks every few seconds #744

freeflyer opened this issue Nov 26, 2012 · 33 comments

Comments

@freeflyer
Copy link

We are using Glassfish 3.1.2 and Atmosphere 1.0.4 in our application.
It's works fine via usual HTTP. But when we trying to work via HTTPS it's working only few first seconds (at most a few tens of seconds). Then we get the following exception:

java.lang.IllegalArgumentException
    at java.nio.Buffer.position(Buffer.java:236)
    at sun.security.ssl.EngineOutputRecord.write(EngineOutputRecord.java:307)
    at sun.security.ssl.EngineOutputRecord.write(EngineOutputRecord.java:268)
    at sun.security.ssl.EngineWriter.writeRecord(EngineWriter.java:185)
    at sun.security.ssl.SSLEngineImpl.writeRecord(SSLEngineImpl.java:1284)
    at sun.security.ssl.SSLEngineImpl.writeAppRecord(SSLEngineImpl.java:1254)
    at sun.security.ssl.SSLEngineImpl.wrap(SSLEngineImpl.java:1169)
    at javax.net.ssl.SSLEngine.wrap(SSLEngine.java:469)
    at com.sun.grizzly.util.SSLUtils.wrap(SSLUtils.java:332)
    at com.sun.grizzly.util.SSLOutputWriter.flushChannel(SSLOutputWriter.java:89)
    at com.sun.grizzly.ssl.SSLAsyncOutputBuffer.flushChannel(SSLAsyncOutputBuffer.java:90)
    at com.sun.grizzly.http.SocketChannelOutputBuffer.flushBuffer(SocketChannelOutputBuffer.java:489)
    at com.sun.grizzly.http.SocketChannelOutputBuffer.flush(SocketChannelOutputBuffer.java:467)
    at com.sun.grizzly.http.ProcessorTask.action(ProcessorTask.java:1276)
    at com.sun.grizzly.ssl.SSLProcessorTask.action(SSLProcessorTask.java:164)
    at com.sun.grizzly.tcp.Response.action(Response.java:268)
    at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:380)
    at org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:353)
    at org.apache.catalina.connector.CoyoteWriter.flush(CoyoteWriter.java:153)
    at com.ourcompany.engine.network.TransportHandler.onRequest(TransportHandler.java:378)
    at org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:256)
    at org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:166)
    at org.atmosphere.container.GrizzlyCometSupport.service(GrizzlyCometSupport.java:119)
    at org.atmosphere.container.GlassFishWebSocketSupport.service(GlassFishWebSocketSupport.java:66)
    at org.atmosphere.cpr.AtmosphereFramework.doCometSupport(AtmosphereFramework.java:1292)
    at org.atmosphere.cpr.AtmosphereServlet.doPost(AtmosphereServlet.java:293)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1542)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
    at com.sun.grizzly.comet.CometEngine.executeServlet(CometEngine.java:444)
    at com.sun.grizzly.comet.CometEngine.handle(CometEngine.java:308)
    at com.sun.grizzly.comet.CometAsyncFilter.doFilter(CometAsyncFilter.java:87)
    at com.sun.grizzly.arp.DefaultAsyncExecutor.invokeFilters(DefaultAsyncExecutor.java:171)
    at com.sun.grizzly.arp.DefaultAsyncExecutor.interrupt(DefaultAsyncExecutor.java:143)
    at com.sun.grizzly.arp.AsyncProcessorTask.doTask(AsyncProcessorTask.java:102)
    at com.sun.grizzly.http.TaskBase.run(TaskBase.java:193)
    at com.sun.grizzly.http.TaskBase.execute(TaskBase.java:175)
    at com.sun.grizzly.arp.DefaultAsyncHandler.handle(DefaultAsyncHandler.java:145)
    at com.sun.grizzly.arp.AsyncProtocolFilter.execute(AsyncProtocolFilter.java:210)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:722)
@rlubke
Copy link
Contributor

rlubke commented Nov 26, 2012

Looks like there is more than one thread referencing the Buffer.

Have you been able to confirm the same behavior on GlassFish 3.1.2.2?

Is this something you can reproduce using the standard Atmosphere examples?

@freeflyer
Copy link
Author

Looks like there is more than one thread referencing the Buffer.

Such use is prohibited? For example can I have list of broadcasters and thread that will periodically call them broadcast method?

Is this something you can reproduce using the standard Atmosphere examples?

I will try to do that.

@jfarcand
Copy link
Member

@freeflyer Can you try with Tomcat or Jetty? From your stack trace I don't see anything wrong. Are you sharing AtmosphereResource amongst threads? If yes you need to make sure the write operation is executed inside a synchronous block.

@Vladimir85
Copy link

I have the same issue when I am trying to broadcast messages with interval up to 100ms between messages.

@freeflyer
Copy link
Author

Is this something you can reproduce using the standard Atmosphere examples?

Today I have tried standard chat atmosphere example (with streaming transport) with the similar results as for our application. Over HTTP it's working fine but over HTTPS behaviour very unstable. Periodically the connection breaks, and some messages are lost. And these errors periodically appears in the log:

[#|2012-12-05T18:05:19.023+0200|WARNING|glassfish3.1.1|javax.enterprise.system.container.web.com.sun.enterprise.web|ThreadID=31;ThreadName=Thread-2;|Response Error during finishResponse
java.lang.IllegalArgumentException
at java.nio.Buffer.position(Buffer.java:218)
at javax.crypto.CipherSpi.a(DashoA13
..)
at javax.crypto.CipherSpi.engineUpdate(DashoA13
..)
at javax.crypto.Cipher.update(DashoA13*..)
at com.sun.net.ssl.internal.ssl.CipherBox.encrypt(CipherBox.java:199)
at com.sun.net.ssl.internal.ssl.EngineOutputRecord.encrypt(EngineOutputRecord.java:127)
at com.sun.net.ssl.internal.ssl.EngineOutputRecord.write(EngineOutputRecord.java:248)
at com.sun.net.ssl.internal.ssl.EngineWriter.writeRecord(EngineWriter.java:165)
at com.sun.net.ssl.internal.ssl.SSLEngineImpl.writeRecord(SSLEngineImpl.java:1168)
at com.sun.net.ssl.internal.ssl.SSLEngineImpl.writeAppRecord(SSLEngineImpl.java:1138)
at com.sun.net.ssl.internal.ssl.SSLEngineImpl.wrap(SSLEngineImpl.java:1053)
at javax.net.ssl.SSLEngine.wrap(SSLEngine.java:452)
at com.sun.grizzly.util.SSLUtils.wrap(SSLUtils.java:330)
at com.sun.grizzly.util.SSLOutputWriter.flushChannel(SSLOutputWriter.java:89)
at com.sun.grizzly.ssl.SSLAsyncOutputBuffer.flushChannel(SSLAsyncOutputBuffer.java:90)
at com.sun.grizzly.http.SocketChannelOutputBuffer.flushBuffer(SocketChannelOutputBuffer.java:398)
at com.sun.grizzly.http.SocketChannelOutputBuffer.endRequest(SocketChannelOutputBuffer.java:389)
at com.sun.grizzly.http.ProcessorTask.action(ProcessorTask.java:1090)
at com.sun.grizzly.ssl.SSLProcessorTask.action(SSLProcessorTask.java:164)
at com.sun.grizzly.tcp.Response.action(Response.java:268)
at com.sun.grizzly.tcp.Response.finish(Response.java:412)
at org.apache.catalina.connector.OutputBuffer.close(OutputBuffer.java:341)
at org.apache.catalina.connector.Response.finishResponse(Response.java:582)
at org.apache.catalina.connector.CoyoteAdapter.afterService(CoyoteAdapter.java:370)
at com.sun.enterprise.v3.services.impl.ContainerMapper.afterService(ContainerMapper.java:366)
at com.sun.grizzly.http.ProcessorTask.finishResponse(ProcessorTask.java:760)
at com.sun.grizzly.http.ProcessorTask.postResponse(ProcessorTask.java:750)
at com.sun.grizzly.arp.DefaultAsyncExecutor.postExecute(DefaultAsyncExecutor.java:198)
at com.sun.grizzly.arp.AsyncProcessorTask.doTask(AsyncProcessorTask.java:101)
at com.sun.grizzly.http.TaskBase.run(TaskBase.java:193)
at com.sun.grizzly.http.TaskBase.execute(TaskBase.java:175)
at com.sun.grizzly.arp.DefaultAsyncHandler.handle(DefaultAsyncHandler.java:145)
at com.sun.grizzly.arp.AsyncProtocolFilter.execute(AsyncProtocolFilter.java:204)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:619)
|#]

[#|2012-12-05T18:05:19.027+0200|SEVERE|glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=30;_ThreadName=Thread-2;|org.apache.catalina.connector.ClientAbortException: java.io.IOException: SSLOutputWriter: BUFFER_OVERFLOW
at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:384)
at org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:353)
at org.apache.catalina.connector.Response.flushBuffer(Response.java:643)
at org.apache.catalina.connector.ResponseFacade.flushBuffer(ResponseFacade.java:328)
at org.atmosphere.cpr.AtmosphereResponse.flushBuffer(AtmosphereResponse.java:457)
at org.atmosphere.interceptor.AtmosphereResourceLifecycleInterceptor$1.onBroadcast(AtmosphereResourceLifecycleInterceptor.java:104)
at org.atmosphere.cpr.AtmosphereResourceImpl.onBroadcast(AtmosphereResourceImpl.java:815)
at org.atmosphere.cpr.AtmosphereResourceImpl.notifyListeners(AtmosphereResourceImpl.java:759)
at org.atmosphere.cpr.AtmosphereResourceImpl.notifyListeners(AtmosphereResourceImpl.java:733)
at org.atmosphere.cpr.DefaultBroadcaster.executeAsyncWrite(DefaultBroadcaster.java:783)
at org.atmosphere.cpr.DefaultBroadcaster$3.run(DefaultBroadcaster.java:811)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.io.IOException: SSLOutputWriter: BUFFER_OVERFLOW
at com.sun.grizzly.util.SSLOutputWriter.flushChannel(SSLOutputWriter.java:98)
at com.sun.grizzly.ssl.SSLAsyncOutputBuffer.flushChannel(SSLAsyncOutputBuffer.java:90)
at com.sun.grizzly.http.SocketChannelOutputBuffer.flushBuffer(SocketChannelOutputBuffer.java:398)
at com.sun.grizzly.http.SocketChannelOutputBuffer.flush(SocketChannelOutputBuffer.java:376)
at com.sun.grizzly.http.ProcessorTask.action(ProcessorTask.java:1247)
at com.sun.grizzly.ssl.SSLProcessorTask.action(SSLProcessorTask.java:164)
at com.sun.grizzly.tcp.Response.action(Response.java:268)
at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:380)
... 16 more

@freeflyer
Copy link
Author

Anybody has used this framework via HTTS? What do you think - this is a problem of the atmospere or streaming via https in general? Or it's just my local issues?

@rlubke
Copy link
Contributor

rlubke commented Dec 5, 2012

I'll be checking into this today. Stay tuned.

freeflyer mailto:notifications@github.com
December 5, 2012 8:42 AM

Anybody has used this framework via HTTS? What do you think - this is
a problem of the atmospere or streaming via https in general? Or it's
just my local issues?


Reply to this email directly or view it on GitHub
#744 (comment).

freeflyer mailto:notifications@github.com
November 26, 2012 10:04 AM

We are using Glassfish 3.1.2 and Atmosphere 1.0.4 in our application.
It's works fine via usual HTTP. But when we trying to work via HTTPS
it's working only few first seconds (at most a few tens of seconds).
Then we get the following exception:

java.lang.IllegalArgumentException
at java.nio.Buffer.position(Buffer.java:236)
at sun.security.ssl.EngineOutputRecord.write(EngineOutputRecord.java:307)
at sun.security.ssl.EngineOutputRecord.write(EngineOutputRecord.java:268)
at sun.security.ssl.EngineWriter.writeRecord(EngineWriter.java:185)
at sun.security.ssl.SSLEngineImpl.writeRecord(SSLEngineImpl.java:1284)
at sun.security.ssl.SSLEngineImpl.writeAppRecord(SSLEngineImpl.java:1254)
at sun.security.ssl.SSLEngineImpl.wrap(SSLEngineImpl.java:1169)
at javax.net.ssl.SSLEngine.wrap(SSLEngine.java:469)
at com.sun.grizzly.util.SSLUtils.wrap(SSLUtils.java:332)
at
com.sun.grizzly.util.SSLOutputWriter.flushChannel(SSLOutputWriter.java:89)
at
com.sun.grizzly.ssl.SSLAsyncOutputBuffer.flushChannel(SSLAsyncOutputBuffer.java:90)
at
com.sun.grizzly.http.SocketChannelOutputBuffer.flushBuffer(SocketChannelOutputBuffer.java:489)
at
com.sun.grizzly.http.SocketChannelOutputBuffer.flush(SocketChannelOutputBuffer.java:467)
at com.sun.grizzly.http.ProcessorTask.action(ProcessorTask.java:1276)
at com.sun.grizzly.ssl.SSLProcessorTask.action(SSLProcessorTask.java:164)
at com.sun.grizzly.tcp.Response.action(Response.java:268)
at
org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:380)
at org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:353)
at org.apache.catalina.connector.CoyoteWriter.flush(CoyoteWriter.java:153)
at
com.ourcompany.engine.network.TransportHandler.onRequest(TransportHandler.java:378)
at
org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:256)
at
org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:166)
at
org.atmosphere.container.GrizzlyCometSupport.service(GrizzlyCometSupport.java:119)
at
org.atmosphere.container.GlassFishWebSocketSupport.service(GlassFishWebSocketSupport.java:66)
at
org.atmosphere.cpr.AtmosphereFramework.doCometSupport(AtmosphereFramework.java:1292)
at org.atmosphere.cpr.AtmosphereServlet.doPost(AtmosphereServlet.java:293)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
at
org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1542)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
at
org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
at
com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
at com.sun.grizzly.comet.CometEngine.executeServlet(CometEngine.java:444)
at com.sun.grizzly.comet.CometEngine.handle(CometEngine.java:308)
at
com.sun.grizzly.comet.CometAsyncFilter.doFilter(CometAsyncFilter.java:87)
at
com.sun.grizzly.arp.DefaultAsyncExecutor.invokeFilters(DefaultAsyncExecutor.java:171)
at
com.sun.grizzly.arp.DefaultAsyncExecutor.interrupt(DefaultAsyncExecutor.java:143)
at
com.sun.grizzly.arp.AsyncProcessorTask.doTask(AsyncProcessorTask.java:102)
at com.sun.grizzly.http.TaskBase.run(TaskBase.java:193)
at com.sun.grizzly.http.TaskBase.execute(TaskBase.java:175)
at
com.sun.grizzly.arp.DefaultAsyncHandler.handle(DefaultAsyncHandler.java:145)
at
com.sun.grizzly.arp.AsyncProtocolFilter.execute(AsyncProtocolFilter.java:210)
at
com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at
com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at
com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at
com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at
com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:722)


Reply to this email directly or view it on GitHub
#744.

@freeflyer
Copy link
Author

Have you been able to confirm the same behavior on GlassFish 3.1.2.2?

Yes. Today I have tried to deploy both our application and standard atmosphere chat example.
In both cases, there are similar problems with the connection.

@freeflyer
Copy link
Author

Can you try with Tomcat or Jetty?

I have tried this. It seems it works!
Standard chat example and even our application capable to work with Tomcat 7.0.33 a long time via HTTPS without connection problems.
At least at first glance. I will continue testing with Tomcat tomorrow.

@rlubke
Copy link
Contributor

rlubke commented Dec 7, 2012

I believe I may have a fix for this (at least it appears that way on my end).

The fix is against Grizzly 1.9.50/GlassFish 3.1.2.2. You can download the updated JAR here [1]. Replace the existing jar in $GF_HOME/modules, restart the server, and test.

Let me know how it goes.

[1]https://dl.dropbox.com/s/b7iv8dhh6rmp029/grizzly-http-1.9.50.jar?dl=1

@freeflyer
Copy link
Author

It seems it does not work. I have tested today this jar witht the GlassFish 3.1.2.2 and standard atmosphere chat example (streaming transport, https). There are following exceptions in the log periodically appears (see below).

[#|2012-12-10T16:41:24.024+0200|WARNING|glassfish3.1.2|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=46;_ThreadName=Thread-2;|Response Error during finishResponse
java.lang.RuntimeException: bytebuffer padding error
at sun.security.ssl.CipherBox.encrypt(CipherBox.java:362)
at sun.security.ssl.EngineOutputRecord.encrypt(EngineOutputRecord.java:148)
at sun.security.ssl.EngineOutputRecord.write(EngineOutputRecord.java:308)
at sun.security.ssl.EngineOutputRecord.write(EngineOutputRecord.java:258)
at sun.security.ssl.EngineWriter.writeRecord(EngineWriter.java:185)
at sun.security.ssl.SSLEngineImpl.writeRecord(SSLEngineImpl.java:1284)
at sun.security.ssl.SSLEngineImpl.writeAppRecord(SSLEngineImpl.java:1254)
at sun.security.ssl.SSLEngineImpl.wrap(SSLEngineImpl.java:1169)
at javax.net.ssl.SSLEngine.wrap(SSLEngine.java:469)
at com.sun.grizzly.util.SSLUtils.wrap(SSLUtils.java:332)
at com.sun.grizzly.util.SSLOutputWriter.flushChannel(SSLOutputWriter.java:89)
at com.sun.grizzly.ssl.SSLAsyncOutputBuffer.flushChannel(SSLAsyncOutputBuffer.java:90)
at com.sun.grizzly.http.SocketChannelOutputBuffer.flushBuffer(SocketChannelOutputBuffer.java:498)
at com.sun.grizzly.http.SocketChannelOutputBuffer.endRequest(SocketChannelOutputBuffer.java:489)
at com.sun.grizzly.http.ProcessorTask.action(ProcessorTask.java:1127)
at com.sun.grizzly.ssl.SSLProcessorTask.action(SSLProcessorTask.java:164)
at com.sun.grizzly.tcp.Response.action(Response.java:268)
at com.sun.grizzly.tcp.Response.finish(Response.java:412)
at org.apache.catalina.connector.OutputBuffer.close(OutputBuffer.java:341)
at org.apache.catalina.connector.Response.finishResponse(Response.java:582)
at org.apache.catalina.connector.CoyoteAdapter.afterService(CoyoteAdapter.java:375)
at com.sun.enterprise.v3.services.impl.ContainerMapper.afterService(ContainerMapper.java:483)
at com.sun.grizzly.http.ProcessorTask.finishResponse(ProcessorTask.java:792)
at com.sun.grizzly.http.ProcessorTask.postResponse(ProcessorTask.java:782)
at com.sun.grizzly.arp.DefaultAsyncExecutor.postExecute(DefaultAsyncExecutor.java:198)
at com.sun.grizzly.arp.AsyncProcessorTask.doTask(AsyncProcessorTask.java:114)
at com.sun.grizzly.http.TaskBase.run(TaskBase.java:193)
at com.sun.grizzly.http.TaskBase.execute(TaskBase.java:175)
at com.sun.grizzly.arp.DefaultAsyncHandler.handle(DefaultAsyncHandler.java:145)
at com.sun.grizzly.arp.AsyncProtocolFilter.execute(AsyncProtocolFilter.java:210)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:722)

@freeflyer
Copy link
Author

And test with the our atmosphere application:

[#|2012-12-10T16:52:22.381+0200|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=113;_ThreadName=Thread-2;|16:52:22,379 DEBUG DefaultBroadcaster:880 : onException()
java.lang.IllegalArgumentException
at java.nio.Buffer.position(Buffer.java:236)
at java.security.MessageDigestSpi.engineUpdate(MessageDigestSpi.java:115)
at java.security.MessageDigest$Delegate.engineUpdate(MessageDigest.java:572)
at java.security.MessageDigest.update(MessageDigest.java:341)
at com.sun.crypto.provider.HmacCore.update(HmacCore.java:188)
at com.sun.crypto.provider.HmacSHA1.engineUpdate(HmacSHA1.java:100)
at javax.crypto.Mac.update(Mac.java:519)
at sun.security.ssl.MAC.compute(MAC.java:227)
at sun.security.ssl.MAC.compute(MAC.java:159)
at sun.security.ssl.EngineOutputRecord.addMAC(EngineOutputRecord.java:123)
at sun.security.ssl.EngineOutputRecord.write(EngineOutputRecord.java:301)
at sun.security.ssl.EngineOutputRecord.write(EngineOutputRecord.java:268)
at sun.security.ssl.EngineWriter.writeRecord(EngineWriter.java:185)
at sun.security.ssl.SSLEngineImpl.writeRecord(SSLEngineImpl.java:1284)
at sun.security.ssl.SSLEngineImpl.writeAppRecord(SSLEngineImpl.java:1254)
at sun.security.ssl.SSLEngineImpl.wrap(SSLEngineImpl.java:1169)
at javax.net.ssl.SSLEngine.wrap(SSLEngine.java:469)
at com.sun.grizzly.util.SSLUtils.wrap(SSLUtils.java:332)
at com.sun.grizzly.util.SSLOutputWriter.flushChannel(SSLOutputWriter.java:89)
at com.sun.grizzly.ssl.SSLAsyncOutputBuffer.flushChannel(SSLAsyncOutputBuffer.java:90)
at com.sun.grizzly.http.SocketChannelOutputBuffer.flushBuffer(SocketChannelOutputBuffer.java:498)
at com.sun.grizzly.http.SocketChannelOutputBuffer.flush(SocketChannelOutputBuffer.java:476)
at com.sun.grizzly.http.ProcessorTask.action(ProcessorTask.java:1287)
at com.sun.grizzly.ssl.SSLProcessorTask.action(SSLProcessorTask.java:164)
at com.sun.grizzly.tcp.Response.action(Response.java:268)
at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:380)
at org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:353)
at org.apache.catalina.connector.CoyoteWriter.flush(CoyoteWriter.java:153)
at com.ourcompany.engine.network.TransportHandler.onStateChange(TransportHandler.java:507)
at org.atmosphere.cpr.DefaultBroadcaster.broadcast(DefaultBroadcaster.java:863)
at org.atmosphere.cpr.DefaultBroadcaster.executeAsyncWrite(DefaultBroadcaster.java:780)
at org.atmosphere.cpr.DefaultBroadcaster$3.run(DefaultBroadcaster.java:811)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
|#]

@jfarcand
Copy link
Member

@freeflyer Can you add in your web.xml the following init-param:

 <init-param>
    <param-name>org.atmosphere.useNative</param-name>
    <param-value>false</param-value>
</init-param>

It will disable Grizzly Comet and use Servlet 3.0, which I suspect possibly work.

@freeflyer
Copy link
Author

I have tried with our application but obtained following exceptions:

[#|2012-12-10T17:38:22.386+0200|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=152;_ThreadName=Thread-2;|17:38:22,382 DEBUG DefaultBroadcaster:880 : onException()
java.lang.IllegalArgumentException
at java.nio.Buffer.position(Buffer.java:236)
at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:337)
at sun.nio.ch.IOUtil.write(IOUtil.java:55)
at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:450)
at com.sun.grizzly.util.OutputWriter.flushChannel(OutputWriter.java:108)
at com.sun.grizzly.util.OutputWriter.flushChannel(OutputWriter.java:76)
at com.sun.grizzly.util.SSLOutputWriter.flushChannel(SSLOutputWriter.java:102)
at com.sun.grizzly.ssl.SSLAsyncOutputBuffer.flushChannel(SSLAsyncOutputBuffer.java:90)
at com.sun.grizzly.http.SocketChannelOutputBuffer.flushBuffer(SocketChannelOutputBuffer.java:489)
at com.sun.grizzly.http.SocketChannelOutputBuffer.flush(SocketChannelOutputBuffer.java:467)
at com.sun.grizzly.http.ProcessorTask.action(ProcessorTask.java:1276)
at com.sun.grizzly.ssl.SSLProcessorTask.action(SSLProcessorTask.java:164)
at com.sun.grizzly.tcp.Response.action(Response.java:268)
at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:380)
at org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:353)
at org.apache.catalina.connector.CoyoteWriter.flush(CoyoteWriter.java:153)
at com.ourcompany.engine.network.TransportHandler.onStateChange(TransportHandler.java:507)
at org.atmosphere.cpr.DefaultBroadcaster.broadcast(DefaultBroadcaster.java:863)
at org.atmosphere.cpr.DefaultBroadcaster.executeAsyncWrite(DefaultBroadcaster.java:780)
at org.atmosphere.cpr.DefaultBroadcaster$3.run(DefaultBroadcaster.java:811)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
|#]

@rlubke
Copy link
Contributor

rlubke commented Dec 10, 2012

When you installed the patch jar, did you see a message in the log pertaining to OSGi updating a bundle?

You did rename the jar from the download link to replace the existing jar, yes?

With this fix in place, I've been unable to reproduce the issue. Maybe you're doing something different? Can you describe how you're triggering the problem?

@freeflyer
Copy link
Author

did you see a message in the log pertaining to OSGi updating a bundle?

Can you tell please what the exact message I should look for in the log?

You did rename the jar from the download link to replace the existing jar, yes?

Yes, I have stopped server, then removed previous grizzly-http.jar, and renamed new jar from the download link.

Can you describe how you're triggering the problem?

I have noticed that more hard to reproduce problem when server started at the local host. But when server started at the other host in our local network these connection problems occurs much more often. If I test with standard chat example I enable comet support for https listener on port 8181. Then I change application.js chat file to use streaming transport. Then I open first chat window via https in the Chrome browser and second chat window in the IE browser. Then I start chating in both windows and wait for the hang. Periodically I try to send a large messages (few hundreds letters).

@rlubke
Copy link
Contributor

rlubke commented Dec 11, 2012

The log message will look something like:

INFO: Updated bundle 111 from /Users/catsnac/files/containers/3.1.2.2/glassfish3/glassfish/modules/grizzly-http.jar

You may also wish to delete the OSGi cache if you're not seeing a message like the above. The osgi-cache directory is in $GF_HOME/domains/.

@freeflyer
Copy link
Author

You may also wish to delete the OSGi cache

I have tried, it seems it works now!

@rlubke
Copy link
Contributor

rlubke commented Dec 12, 2012

Ok, that's good to hear! Will work on getting a new Grizzly release out that includes the fix. Will follow up here when it's ready.

@rlubke
Copy link
Contributor

rlubke commented Dec 12, 2012

For future reference, here is the issue within the Grizzly tracker: http://java.net/jira/browse/GRIZZLY-1376.

@jfarcand
Copy link
Member

Thanks Ryan!!

@rlubke
Copy link
Contributor

rlubke commented Dec 12, 2012

I've released Grizzly 1.9.55 which includes a finalized version of the fix.

I've uploaded [1] a simple shell script to obtain all of the Grizzly 1.9.55 jars necessary to upgrade a GlassFish 3.1.2.2 installation. You may want to backup the grizzly jars in your modules directory, then run the script and copy the jars over to your GF installation. You'll probably want to delete the OSGi cache again before starting the server.

NOTE: That if you have a support contract, this may raise the hackles of any support engineers you talk to. If you wish to avoid that situation, use your support channel to get an office GF release that includes 1.9.55.

[1] https://dl.dropbox.com/s/yl0zwt9k4p7orrp/getjars.sh?dl=1

@freeflyer
Copy link
Author

https://dl.dropbox.com/s/yl0zwt9k4p7orrp/getjars.sh?dl=1

I've tried Glassfish 3.1.2.2 with these jars but the following exception occurs during start domain:
(but with the previous patched single jar it's working fine)

[#|2012-12-13T12:49:33.262+0200|SEVERE|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=10;_ThreadName=Thread-2;|java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.enterprise.glassfish.bootstrap.GlassFishMain.main(GlassFishMain.java:97)
at com.sun.enterprise.glassfish.bootstrap.ASMain.main(ASMain.java:55)
Caused by: com.sun.enterprise.module.ResolveError: Failed to start Bundle Id [67] State [INSTALLED] [org.glassfish.main.common.container-common(Container Common):3.1.2.1-SNAPSHOT]
at org.jvnet.hk2.osgiadapter.OSGiModuleImpl.start(OSGiModuleImpl.java:177)
at org.jvnet.hk2.osgiadapter.OSGiModuleImpl$2$1$1.loadClass(OSGiModuleImpl.java:344)
at com.sun.hk2.component.LazyInhabitant.loadClass(LazyInhabitant.java:124)
at com.sun.hk2.component.LazyInhabitant.fetch(LazyInhabitant.java:111)
at com.sun.hk2.component.EventPublishingInhabitant.get(EventPublishingInhabitant.java:135)
at com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:78)
at org.jvnet.hk2.component.Habitat.getComponent(Habitat.java:798)
at com.sun.grizzly.config.Utils.newInstance(Utils.java:160)
at com.sun.grizzly.config.GrizzlyEmbeddedHttp.loadAsyncFilter(GrizzlyEmbeddedHttp.java:520)
at com.sun.grizzly.config.GrizzlyEmbeddedHttp.loadCometAsyncFilter(GrizzlyEmbeddedHttp.java:497)
at com.sun.grizzly.config.GrizzlyEmbeddedHttp.enableComet(GrizzlyEmbeddedHttp.java:459)
at com.sun.grizzly.config.GrizzlyEmbeddedHttp.configureProtocol(GrizzlyEmbeddedHttp.java:344)
at com.sun.grizzly.config.GrizzlyEmbeddedHttp.configure(GrizzlyEmbeddedHttp.java:297)
at com.sun.grizzly.config.GrizzlyServiceListener.initializeListener(GrizzlyServiceListener.java:104)
at com.sun.grizzly.config.GrizzlyServiceListener.configure(GrizzlyServiceListener.java:89)
at com.sun.enterprise.v3.services.impl.GrizzlyListener.configure(GrizzlyListener.java:84)
at com.sun.enterprise.v3.services.impl.GrizzlyProxy.configureGrizzly(GrizzlyProxy.java:162)
at com.sun.enterprise.v3.services.impl.GrizzlyProxy.(GrizzlyProxy.java:121)
at com.sun.enterprise.v3.services.impl.GrizzlyService.createNetworkProxy(GrizzlyService.java:494)
at com.sun.enterprise.v3.services.impl.GrizzlyService.postConstruct(GrizzlyService.java:402)
at com.sun.hk2.component.AbstractCreatorImpl.inject(AbstractCreatorImpl.java:131)
at com.sun.hk2.component.ConstructorCreator.initialize(ConstructorCreator.java:91)
at com.sun.hk2.component.AbstractCreatorImpl.get(AbstractCreatorImpl.java:82)
at com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:67)
at com.sun.hk2.component.EventPublishingInhabitant.get(EventPublishingInhabitant.java:139)
at com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:78)
at com.sun.enterprise.v3.server.AppServerStartup.run(AppServerStartup.java:253)
at com.sun.enterprise.v3.server.AppServerStartup.doStart(AppServerStartup.java:145)
at com.sun.enterprise.v3.server.AppServerStartup.start(AppServerStartup.java:136)
at com.sun.enterprise.glassfish.bootstrap.GlassFishImpl.start(GlassFishImpl.java:79)
at com.sun.enterprise.glassfish.bootstrap.GlassFishDecorator.start(GlassFishDecorator.java:63)
at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiGlassFishImpl.start(OSGiGlassFishImpl.java:69)
at com.sun.enterprise.glassfish.bootstrap.GlassFishMain$Launcher.launch(GlassFishMain.java:117)
... 6 more
Caused by: org.osgi.framework.BundleException: Unresolved constraint in bundle org.glassfish.main.common.container-common [67]: Unable to resolve 67.0: missing requirement [67.0] osgi.wiring.package; (&(osgi.wiring.package=com.sun.grizzly.websockets)(version>=1.9.0)) [caused by: Unable to resolve 117.0: missing requirement [117.0] osgi.wiring.package; (&(osgi.wiring.package=com.sun.grizzly.http.servlet)(version>=1.9.55))]
at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3826)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1868)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:944)
at org.jvnet.hk2.osgiadapter.OSGiModuleImpl.start(OSGiModuleImpl.java:169)
... 38 more
|#]

@rlubke
Copy link
Contributor

rlubke commented Dec 17, 2012

OSGi can be such a pain at times. I'll give it shot on this end as soon as I get some free time.

@freeflyer
Copy link
Author

Thanks, I will wait for news.

@rlubke
Copy link
Contributor

rlubke commented Dec 18, 2012

OK, it wasn't OSGi, it was me and a typo in the script.

I've pushed a new version [1] to dropbox.

[1] https://dl.dropbox.com/s/yl0zwt9k4p7orrp/getjars.sh?dl=1

@rlubke
Copy link
Contributor

rlubke commented Dec 19, 2012

I'm going to go ahead and close this out at this point - not really an atmosphere issue anyway.

The Grizzly issue, if any additional follow up is necessary, is here [1].

[1] http://java.net/jira/browse/GRIZZLY-1376

@rlubke rlubke closed this as completed Dec 19, 2012
@abhisoni96
Copy link

I am new to atmosphere framework and facing same issue. I am using atmosphere spade server 0.7.1 with atmosphere 1.0.0. Will it get solved using latest jars of spade server.

@jfarcand
Copy link
Member

@abhisoni96 The Spade Server is no longer supported. I recommend you use Grizzly 2 implementation instead.

@abhisoni96
Copy link

Sorry for late reply.
Now I am using "grizzly-webserver 1.9.55" and attach also grizzly atmosphere plugin "atmosphere-grizzly-adapter 0.8.7" with atmosphere-jersey 1.0.0.
But i am getting exception as NoClassDefError for class CometSupport while initializing AtmosphereAdapter.
I didn't get why this class CometSupport is not present in atmosphere-runtime 1.0.0.

@jfarcand
Copy link
Member

@abhisoni96 Your configuration is not supported and you are mixing artifacts and version. Either you use 0.8.7 completely, or migrate to 1.0.12. The Spade server is not supported anymore/

@abhisoni96
Copy link

So my question is there any updated plugin "atmosphere-grizzly-adapter" for atmosphere-jersey 1.0.0.
Or i have to add my own AtmosphereAdapter.

@abhisoni96
Copy link

I migrate to 1.0.0 and it is working fine with ServletAdapter . Thank you.

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

No branches or pull requests

5 participants