Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6207619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:39:45+00:00 2026-05-24T05:39:45+00:00

t have created a service for sending push notification to iPhone by using APNS-SHARP

  • 0

t have created a service for sending push notification to iPhone by using APNS-SHARP .while closing the connection i am getting an error that
” A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 17.149.34.140:2195.” below is my code

    public void SendPushNotificationToiPhone()
    {
        try
        {
            int iPhoneCount = 1;
            NotificationService pushNotificationService = null;
            using (WhatsNewAtDbEntities entityObject = new WhatsNewAtDbEntities())
            {
                var activeiPhoneDevices = from items in entityObject.PushNotifications
                                          where items.IsActive == 1 &&
                                          items.Make == 2
                                          select items;

                int activeiPhoneDevicesCount = activeiPhoneDevices.Count();

                foreach (var activeDevicesDetails in activeiPhoneDevices)
                {
                    string deviceToken = activeDevicesDetails.NotificationUrl;
                    int counter = 0;

                    using (WhatsNewAtDbEntities objnewent = new WhatsNewAtDbEntities())
                    {
                        List<ContentCount_Result> count = objnewent.ContentCount(activeDevicesDetails.UserID, activeDevicesDetails.TenantID).ToList<ContentCount_Result>();
                        counter = Convert.ToInt32(count[0].Notificationcount);
                    }

                    if (iPhoneCount == 1)
                    {
                        //True if you are using sandbox certificate, or false if using production
                        bool sandbox = Convert.ToBoolean(AzureData.GetConfigurationSetting("sandBoxCert"));
                        string p12File = AzureData.GetConfigurationSetting("certName");
                        string p12FilePassword = AzureData.GetConfigurationSetting("certPassword");

                        string p12Filename = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, p12File);
                        pushNotificationService = new NotificationService(sandbox, p12Filename, p12FilePassword, 1);

                        pushNotificationService.SendRetries = 5; //5 retries before generating notificationfailed event
                        pushNotificationService.ReconnectDelay = 5000; //5 seconds 

                    }
                    Notification alertNotification = new Notification(deviceToken);
                    if (counter > 0)
                    {
                        alertNotification.Payload.Badge = counter;
                    }
                    else if (counter == 0)
                    {
                        //for resseting the badge value to 0(zero).
                        alertNotification.Payload.Badge.GetValueOrDefault(0);
                    }

                    //Queue the notification to be sent
                    pushNotificationService.QueueNotification(alertNotification);

                    if (iPhoneCount == activeiPhoneDevicesCount)
                    {
                        //First, close the service.
                        pushNotificationService.Close(); --**Getting error here**
                        ////Clean up
                        pushNotificationService.Dispose();
                    }

                    iPhoneCount++;
                }
            }
        }
        catch (Exception)
        {

        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T05:39:45+00:00Added an answer on May 24, 2026 at 5:39 am

    Got solved there was an bug in the apns sharp lib

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been using https://github.com/Redth/APNS-Sharp to send push notification message to all devices where
I have created a web service which has a couple of methods developed using
I have created a C# service using the VS2005 template. It works fine however
I have created a web service in a virtual directory using VS 2008. I
i have a data service hosted in azure from which i am sending notification
I have created an web service I need to publish this service. I need
I have created a web service via WCF. Then I exposed it as a
I have created a Windows Service in VB.net for building xML from a database.
I have created a WCF service for uploading images , which accepts System.IO.Stream as
We have created a WCF service hosted in a windows service that handles Authentication

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.