title: java.io.EOFException: SSL peer shut down incorrectly
body: <p>I have the following code:</p>
  
  <pre><code>package daoImp;
  
  import java.util.List;
  
  import javapns.Push;
  import javapns.communication.exceptions.KeystoreException;
  import javapns.notification.PushedNotification;
  import javapns.notification.ResponsePacket;
  import org.json.JSONException;
  import com.sun.jmx.snmp.daemon.CommunicationException;
  
  public class Notification {
  
      public static void main(String args[]) {
          try {
              new Notification().sendMessageToAPN();
          } catch (CommunicationException | KeystoreException | JSONException
                  | javapns.communication.exceptions.CommunicationException e) {
              e.printStackTrace();
          }
      }
  
      public void sendMessageToAPN() throws CommunicationException,
              KeystoreException, JSONException,
              javapns.communication.exceptions.CommunicationException {
          String regId1 = "6f9d340ab4d0f81206f7d8c1ab7b8994d90d139e0d1d2b99999b02887e60d54f";
          List&lt;PushedNotification&gt; notifications = Push.alert("hello","C:/Program Files (x86)/Java/jdk1.7.0_21/jre/lib/security/gameover.p12", "gameover",
                  false, regId1);
          for (PushedNotification notification : notifications) {
              if (notification.isSuccessful()) {
                  System.out.println("Push notification sent successfully to: " + notification.getDevice().getToken());
  
              } else {
                  String invalidToken = notification.getDevice().getToken();
                  System.err.println("Invalid Token " + invalidToken);
  
                  System.out.println(" The problem was");
                  Exception theProblem = notification.getException();
                  theProblem.printStackTrace();
  
                  ResponsePacket theErrorResponse = notification.getResponse();
                  if (theErrorResponse != null) {
                      System.out.println(theErrorResponse.getMessage());
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>When I run the code, I get the following exception message: <code>handshake to ssl failed as connection to remote host failed during handshake</code>.</p>
  
  <pre><code>log4j:WARN No appenders could be found for logger (javapns.notification.Payload).
  log4j:WARN Please initialize the log4j system properly.
  Invalid Token 6f9d340ab4d0f81206f7d8c1ab7b6774d90d139e0d1d2b58599b02887e60d54f
   The problem was
  javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
      at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
      at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
      at sun.security.ssl.SSLSocketImpl.writeRecord(Unknown Source)
      at sun.security.ssl.AppOutputStream.write(Unknown Source)
      at java.io.OutputStream.write(Unknown Source)
      at javapns.notification.PushNotificationManager.sendNotification(PushNotificationManager.java:402)
      at javapns.notification.PushNotificationManager.sendNotification(PushNotificationManager.java:350)
      at javapns.notification.PushNotificationManager.sendNotification(PushNotificationManager.java:320)
      at javapns.Push.sendPayload(Push.java:177)
      at javapns.Push.alert(Push.java:47)
      at daoImp.Notification.sendMessageToAPN(Notification.java:27)
      at daoImp.Notification.main(Notification.java:16)
  Caused by: java.io.EOFException: SSL peer shut down incorrectly
      at sun.security.ssl.InputRecord.read(Unknown Source)
      ... 12 more
  </code></pre>
  
  <p>I don't know why I'm getting this message.</p>