title: Pushy APNS: No route to host
body: <p>I am trying to send iOS push notifications using the <a href="https://github.com/jchambers/pushy" rel="nofollow noreferrer">Pushy</a> Java library.  The code to send the APNS looks like this:</p>
  <pre><code>String topic = &quot;XXX&quot;;
          ApnsClient apnsClient = new ApnsClientBuilder().setApnsServer(ApnsClientBuilder.DEVELOPMENT_APNS_HOST)
                  .setClientCredentials(new File(
                          &quot;/Users/sdnakhla/Developer/eclipse-workspace/mdm/mdm-server/src/site/certs/apns_a5400831-a2db-480b-9487-52cfe61fc4f0.p12&quot;),
                          &quot;Password123!&quot;)
                  .build();
          ApnsPayloadBuilder payloadBuilder = new SimpleApnsPayloadBuilder();
          String payload = payloadBuilder.buildMdmPayload(magic);
          String sanitizedToken = TokenUtil.sanitizeTokenString(deviceToken);
  
          try {
              SimpleApnsPushNotification pushNotification = new SimpleApnsPushNotification(sanitizedToken, topic,
                      payload);
              PushNotificationResponse&lt;SimpleApnsPushNotification&gt; pushNotificationResponse = apnsClient
                      .sendNotification(pushNotification).get();
  
              if (pushNotificationResponse.isAccepted()) {
                  if (logger.isDebugEnabled()) {
                      logger.debug(&quot;testCheckin(String, String) - {}&quot;, &quot;Push notification accepted by APNs gateway.&quot;); //$NON-NLS-1$ //$NON-NLS-2$
                  }
              } else {
                  if (logger.isDebugEnabled()) {
                      logger.debug(&quot;testCheckin(String, String) - {}&quot;, //$NON-NLS-1$
                              &quot;Notification rejected by the APNs gateway: &quot; //$NON-NLS-1$
                                      + pushNotificationResponse.getRejectionReason());
                  }
  
                  pushNotificationResponse.getTokenInvalidationTimestamp().ifPresent(timestamp -&gt; {
                      System.out.println(&quot;\t…and the token is invalid as of &quot; + timestamp);
                  });
              }
          } catch (Exception e) {
              logger.warn(&quot;testCheckin(String, String) - exception ignored&quot;, e); //$NON-NLS-1$
          }
  </code></pre>
  <p>Much of this is taken straight from the documentation.  When I run the code, though, I get the following Exception:</p>
  <pre><code>15:55:58 WARN  [com.eatthepath.pushy.apns.ApnsChannelPool] Failed to create channel: io.netty.resolver.dns.DnsResolveContext$SearchDomainUnknownHostException: Failed to resolve 'api.sandbox.push.apple.com' and search domain query for configured domains failed as well: [lan]
      at io.netty.resolver.dns.DnsResolveContext.finishResolve(DnsResolveContext.java:1047)
      at io.netty.resolver.dns.DnsResolveContext.tryToFinishResolve(DnsResolveContext.java:1000)
      at io.netty.resolver.dns.DnsResolveContext.query(DnsResolveContext.java:418)
      at io.netty.resolver.dns.DnsResolveContext.access$600(DnsResolveContext.java:66)
      at io.netty.resolver.dns.DnsResolveContext$2.operationComplete(DnsResolveContext.java:467)
      at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:578)
      at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:571)
      at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:550)
      at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:491)
      at io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:616)
      at io.netty.util.concurrent.DefaultPromise.setFailure0(DefaultPromise.java:609)
      at io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:117)
      at io.netty.resolver.dns.DnsQueryContext.tryFailure(DnsQueryContext.java:256)
      at io.netty.resolver.dns.DnsQueryContext.onQueryWriteCompletion(DnsQueryContext.java:193)
      at io.netty.resolver.dns.DnsQueryContext.access$200(DnsQueryContext.java:43)
      at io.netty.resolver.dns.DnsQueryContext$3.operationComplete(DnsQueryContext.java:185)
      at io.netty.resolver.dns.DnsQueryContext$3.operationComplete(DnsQueryContext.java:182)
      at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:578)
      at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:552)
      at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:491)
      at io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:616)
      at io.netty.util.concurrent.DefaultPromise.setFailure0(DefaultPromise.java:609)
      at io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:117)
      at io.netty.util.internal.PromiseNotificationUtil.tryFailure(PromiseNotificationUtil.java:64)
      at io.netty.channel.ChannelOutboundBuffer.safeFail(ChannelOutboundBuffer.java:723)
      at io.netty.channel.ChannelOutboundBuffer.remove0(ChannelOutboundBuffer.java:308)
      at io.netty.channel.ChannelOutboundBuffer.remove(ChannelOutboundBuffer.java:288)
      at io.netty.channel.nio.AbstractNioMessageChannel.doWrite(AbstractNioMessageChannel.java:158)
      at io.netty.channel.AbstractChannel$AbstractUnsafe.flush0(AbstractChannel.java:931)
      at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.flush0(AbstractNioChannel.java:354)
      at io.netty.channel.AbstractChannel$AbstractUnsafe.flush(AbstractChannel.java:895)
      at io.netty.channel.DefaultChannelPipeline$HeadContext.flush(DefaultChannelPipeline.java:1372)
      at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:750)
      at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:742)
      at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:728)
      at io.netty.channel.DefaultChannelPipeline.flush(DefaultChannelPipeline.java:967)
      at io.netty.channel.AbstractChannel.flush(AbstractChannel.java:254)
      at io.netty.resolver.dns.DnsNameResolver.flushQueries(DnsNameResolver.java:1257)
      at io.netty.resolver.dns.DnsResolveContext.internalResolve(DnsResolveContext.java:361)
      at io.netty.resolver.dns.DnsResolveContext.doSearchDomainQuery(DnsResolveContext.java:284)
      at io.netty.resolver.dns.DnsAddressResolveContext.doSearchDomainQuery(DnsAddressResolveContext.java:96)
      at io.netty.resolver.dns.DnsResolveContext.resolve(DnsResolveContext.java:249)
      at io.netty.resolver.dns.DnsNameResolver.doResolveAllUncached0(DnsNameResolver.java:1158)
      at io.netty.resolver.dns.DnsNameResolver.doResolveAllUncached(DnsNameResolver.java:1131)
      at io.netty.resolver.dns.DnsNameResolver.doResolveAll(DnsNameResolver.java:1080)
      at io.netty.resolver.dns.DnsNameResolver.doResolveAll(DnsNameResolver.java:1048)
      at io.netty.resolver.SimpleNameResolver.resolveAll(SimpleNameResolver.java:79)
      at io.netty.resolver.dns.InflightNameResolver.resolve(InflightNameResolver.java:96)
      at io.netty.resolver.dns.InflightNameResolver.resolveAll(InflightNameResolver.java:71)
      at io.netty.resolver.dns.InflightNameResolver.resolveAll(InflightNameResolver.java:56)
      at io.netty.resolver.RoundRobinInetAddressResolver.doResolve(RoundRobinInetAddressResolver.java:55)
      at io.netty.resolver.SimpleNameResolver.resolve(SimpleNameResolver.java:61)
      at io.netty.resolver.SimpleNameResolver.resolve(SimpleNameResolver.java:53)
      at io.netty.resolver.InetSocketAddressResolver.doResolve(InetSocketAddressResolver.java:55)
      at io.netty.resolver.InetSocketAddressResolver.doResolve(InetSocketAddressResolver.java:31)
      at io.netty.resolver.AbstractAddressResolver.resolve(AbstractAddressResolver.java:106)
      at io.netty.bootstrap.Bootstrap.doResolveAndConnect0(Bootstrap.java:206)
      at io.netty.bootstrap.Bootstrap.doResolveAndConnect(Bootstrap.java:162)
      at io.netty.bootstrap.Bootstrap.connect(Bootstrap.java:116)
      at com.eatthepath.pushy.apns.ApnsChannelFactory.lambda$create$3(ApnsChannelFactory.java:175)
      at io.netty.util.concurrent.PromiseTask.runTask(PromiseTask.java:98)
      at io.netty.util.concurrent.ScheduledFutureTask.run(ScheduledFutureTask.java:153)
      at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174)
      at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167)
      at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
      at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:503)
      at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
      at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
      at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
      at java.base/java.lang.Thread.run(Thread.java:833)
  Caused by: io.netty.resolver.dns.DnsNameResolverException: [/[2001:4860:4860:0:0:0:0:8844]:53] failed to send a query via UDP (no stack trace available)
  Caused by: java.net.NoRouteToHostException: No route to host
      at java.base/sun.nio.ch.DatagramChannelImpl.send0(Native Method)
      at java.base/sun.nio.ch.DatagramChannelImpl.sendFromNativeBuffer(DatagramChannelImpl.java:901)
      at java.base/sun.nio.ch.DatagramChannelImpl.send(DatagramChannelImpl.java:863)
      at java.base/sun.nio.ch.DatagramChannelImpl.send(DatagramChannelImpl.java:821)
      at io.netty.channel.socket.nio.NioDatagramChannel.doWriteMessage(NioDatagramChannel.java:296)
      at io.netty.channel.nio.AbstractNioMessageChannel.doWrite(AbstractNioMessageChannel.java:143)
      at io.netty.channel.AbstractChannel$AbstractUnsafe.flush0(AbstractChannel.java:931)
      at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.flush0(AbstractNioChannel.java:354)
      at io.netty.channel.AbstractChannel$AbstractUnsafe.flush(AbstractChannel.java:895)
      at io.netty.channel.DefaultChannelPipeline$HeadContext.flush(DefaultChannelPipeline.java:1372)
      at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:750)
      at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:742)
      at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:728)
      at io.netty.channel.DefaultChannelPipeline.flush(DefaultChannelPipeline.java:967)
      at io.netty.channel.AbstractChannel.flush(AbstractChannel.java:254)
      at io.netty.resolver.dns.DnsNameResolver.flushQueries(DnsNameResolver.java:1257)
      at io.netty.resolver.dns.DnsResolveContext.internalResolve(DnsResolveContext.java:361)
      at io.netty.resolver.dns.DnsResolveContext.doSearchDomainQuery(DnsResolveContext.java:284)
      at io.netty.resolver.dns.DnsAddressResolveContext.doSearchDomainQuery(DnsAddressResolveContext.java:96)
      at io.netty.resolver.dns.DnsResolveContext.resolve(DnsResolveContext.java:249)
      at io.netty.resolver.dns.DnsNameResolver.doResolveAllUncached0(DnsNameResolver.java:1158)
      at io.netty.resolver.dns.DnsNameResolver.doResolveAllUncached(DnsNameResolver.java:1131)
      at io.netty.resolver.dns.DnsNameResolver.doResolveAll(DnsNameResolver.java:1080)
      at io.netty.resolver.dns.DnsNameResolver.doResolveAll(DnsNameResolver.java:1048)
      at io.netty.resolver.SimpleNameResolver.resolveAll(SimpleNameResolver.java:79)
      at io.netty.resolver.dns.InflightNameResolver.resolve(InflightNameResolver.java:96)
      at io.netty.resolver.dns.InflightNameResolver.resolveAll(InflightNameResolver.java:71)
      at io.netty.resolver.dns.InflightNameResolver.resolveAll(InflightNameResolver.java:56)
      at io.netty.resolver.RoundRobinInetAddressResolver.doResolve(RoundRobinInetAddressResolver.java:55)
      at io.netty.resolver.SimpleNameResolver.resolve(SimpleNameResolver.java:61)
      at io.netty.resolver.SimpleNameResolver.resolve(SimpleNameResolver.java:53)
      at io.netty.resolver.InetSocketAddressResolver.doResolve(InetSocketAddressResolver.java:55)
      at io.netty.resolver.InetSocketAddressResolver.doResolve(InetSocketAddressResolver.java:31)
      at io.netty.resolver.AbstractAddressResolver.resolve(AbstractAddressResolver.java:106)
      at io.netty.bootstrap.Bootstrap.doResolveAndConnect0(Bootstrap.java:206)
      at io.netty.bootstrap.Bootstrap.doResolveAndConnect(Bootstrap.java:162)
      at io.netty.bootstrap.Bootstrap.connect(Bootstrap.java:116)
      at com.eatthepath.pushy.apns.ApnsChannelFactory.lambda$create$3(ApnsChannelFactory.java:175)
      at io.netty.util.concurrent.PromiseTask.runTask(PromiseTask.java:98)
      at io.netty.util.concurrent.ScheduledFutureTask.run(ScheduledFutureTask.java:153)
      at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174)
      at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167)
      at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
      at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:503)
      at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
      at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
      at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
      at java.base/java.lang.Thread.run(Thread.java:833)
  </code></pre>
  <p>Am I doing something wrong here?  Is there a different Java APNS library I should be using?</p>