anchor.diff:  
   %% @hidden
   -spec handle_cast(stop | #apns_msg{}, state()) -> {noreply, state()} | {stop, normal | {error, term()}, state()}.
  +handle_cast(Msg, State=#state{out_socket=undefined,connection=Connection}) ->
  +  try
  +    error_logger:info_msg("Reconnecting to APNS...~n"),
  +    case open_out(Connection) of
  +      {ok, Socket} -> handle_cast(Msg, State#state{out_socket=Socket});
  +      {error, Reason} -> {stop, Reason}
  +    end
  +  catch
  +    _:{error, Reason2} -> {stop, Reason2}
  +  end;
  +
   handle_cast(Msg, State) when is_record(Msg, apns_msg) ->
     Socket = State#state.out_socket,
     Payload = build_payload([{alert, Msg#apns_msg.alert},
  
positive.code:     {error, Reason} ->
        {stop, {error, Reason}, State}
    end;
  handle_cast(stop, State) ->
    {stop, normal, State}.
  
  
negative.code:     NextBuffer -> %% We need to wait for the rest of the message
        {noreply, State#state{in_buffer = NextBuffer}}
    end;
  
  handle_info({ssl_closed, SslSocket}, State = #state{in_socket = SslSocket,
                                                      connection= Connection}) ->
    error_logger:info_msg("Feedback server disconnected. Waiting ~p millis to connect again...~n",
                          [Connection#apns_connection.feedback_timeout]),
    _Timer = erlang:send_after(Connection#apns_connection.feedback_timeout, self(), reconnect),
    {noreply, State#state{in_socket = undefined}};
  
  handle_info(reconnect, State = #state{connection = Connection}) ->
    error_logger:info_msg("Reconnecting the Feedback server...~n"),
    case open_feedback(Connection) of
      {ok, InSocket} -> {noreply, State#state{in_socket = InSocket}};
      {error, Reason} -> {stop, {in_closed, Reason}, State}
    end;
  
  handle_info({ssl_closed, SslSocket}, State = #state{out_socket = SslSocket}) ->
    error_logger:info_msg("APNS disconnected~n"),
    {noreply, State#state{out_socket=undefined}};
  
  handle_info(Request, State) ->
    {stop, {unknown_request, Request}, State}.
  
  