question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

java.lang.IllegalStateException: Channel closed before HTTP/2 preface completed

See original GitHub issue

I have a problem when connecting to APNS (using pushy version 0.7.3):

java.lang.IllegalStateException: Channel closed before HTTP/2 preface completed.
 at com.relayrides.pushy.apns.ApnsClient$2.operationComplete(ApnsClient.java:712)
 at com.relayrides.pushy.apns.ApnsClient$2.operationComplete(ApnsClient.java:704)
 at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:518)
 at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:492)
 at io.netty.util.concurrent.DefaultPromise.notifyListenersWithStackOverFlowProtection(DefaultPromise.java:431)
 at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:420)
 at io.netty.util.concurrent.DefaultPromise.trySuccess(DefaultPromise.java:108)
 at io.netty.channel.DefaultChannelPromise.trySuccess(DefaultChannelPromise.java:82)
 at io.netty.channel.AbstractChannel$CloseFuture.setClosed(AbstractChannel.java:1049)
 at io.netty.channel.AbstractChannel$AbstractUnsafe.doClose0(AbstractChannel.java:674)
 at io.netty.channel.AbstractChannel$AbstractUnsafe.close(AbstractChannel.java:652)
 at io.netty.channel.AbstractChannel$AbstractUnsafe.close(AbstractChannel.java:596)
 at io.netty.channel.DefaultChannelPipeline$HeadContext.close(DefaultChannelPipeline.java:1256)
 at io.netty.channel.AbstractChannelHandlerContext.invokeClose(AbstractChannelHandlerContext.java:610)
 at io.netty.channel.AbstractChannelHandlerContext.close(AbstractChannelHandlerContext.java:594)
 at io.netty.channel.ChannelOutboundHandlerAdapter.close(ChannelOutboundHandlerAdapter.java:71)
 at io.netty.channel.AbstractChannelHandlerContext.invokeClose(AbstractChannelHandlerContext.java:610)
 at io.netty.channel.AbstractChannelHandlerContext.close(AbstractChannelHandlerContext.java:594)
 at io.netty.handler.ssl.SslHandler.closeOutboundAndChannel(SslHandler.java:1250)
 at io.netty.handler.ssl.SslHandler.close(SslHandler.java:459)
 at io.netty.channel.AbstractChannelHandlerContext.invokeClose(AbstractChannelHandlerContext.java:610)
 at io.netty.channel.AbstractChannelHandlerContext.close(AbstractChannelHandlerContext.java:594)
 at io.netty.channel.AbstractChannelHandlerContext.close(AbstractChannelHandlerContext.java:451)
 at io.netty.channel.DefaultChannelPipeline.close(DefaultChannelPipeline.java:943)
 at io.netty.channel.AbstractChannel.close(AbstractChannel.java:227)
 at io.netty.channel.ChannelFutureListener$2.operationComplete(ChannelFutureListener.java:56)
 at io.netty.channel.ChannelFutureListener$2.operationComplete(ChannelFutureListener.java:52)
 at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:518)
 at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:511)
 at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:490)
 at io.netty.util.concurrent.DefaultPromise.notifyListenersWithStackOverFlowProtection(DefaultPromise.java:431)
 at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:420)
 at io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:126)
 at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.fulfillConnectPromise(AbstractNioChannel.java:325)
 at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:341)
 at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:580)
 at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:504)
 at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:418)
 at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:390)
 at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:742)
 at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:145)
 at java.lang.Thread.run(Thread.java:745)

The code, when stripped off of my constants, is

        apnsClient = new ApnsClient<>(
                MyApnsClient.class.getResourceAsStream("MyCertificate.p12"),
                "password");
        Future<Void> connectFuture = apnsClient.connect(
                ApnsClient.DEVELOPMENT_APNS_HOST,
                ApnsClient.DEFAULT_APNS_PORT);
        connectFuture.get(10_000, TimeUnit.MILLISECONDS); // here the exception happens

It worked fine on several different hosts previously (development, staging). The problem happened on the production host on the first deploy.

Are there any workarounds possible? Should I try connecting several times? Should I wait longer? This happened in the environment that I don’t control, so I’ll have to account for such situations in the code… Deployers refused to proceed further until I do something about it and claim the problem to be resolved (:

If more information is necessary, I’ll be happy to provide it. Thank you.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jchamberscommented, Dec 7, 2016

@agyorev Sounds like there’s some kind of version mismatch between Netty and whichever version of netty-tcnative you’re trying to use. Are you using either (a) Windows or (b) Tomcat?

0reactions
agyorevcommented, Dec 8, 2016

@jchambers Nope, Jetty.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java.lang.IllegalStateException: Channel closed before HTTP ...
java.lang.IllegalStateException: Channel closed before HTTP/2 preface completed. at com.turo.pushy.apns.ApnsChannelFactory$3$2.
Read more >
java.lang.IllegalStateException: Channel closed ... - GitHub
java.lang.IllegalStateException: Channel closed before HTTP/2 preface completed. at com.relayrides.pushy.apns.ApnsClient$2.
Read more >
java.lang.IllegalStateException: Channel closed before HTTP ...
I get below error after upgrading pushy from 0.9 to 0.11. java.lang.IllegalStateException: Channel closed before HTTP/2 preface completed.
Read more >
Pushy APNS http2 protocol - No init method in io.netty.util ...
After checking the netty-common version, I noticed that the netty version is not 4.1.48.Final And I am using Spring version 2.0.1.
Read more >
com.turo.pushy.apns.ApnsChannelFactory.java Source code
SocketChannel; import io.netty.handler.codec.http2. ... tryFailure( new IllegalStateException("Channel closed before HTTP/2 preface completed.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found