Can't open push channel all the sudden!***Help!!***

Category: windows phone push

Question

Dutton Designs on Wed, 19 Jun 2013 01:02:10


Hello,

I've had code that has worked fine since I've released my app in Jan...but now all of the sudden, my app's push channel won't open anymore...keep getting the "null" error in the handler.  The error text is "The channel does not exist, but could not be opened.  Try opening the channel again."

Is anyone else having this issue?  I haven't touched anything!  Here is my code...

        public PushChannelWebClient(String _deviceID)
        {
            System.Diagnostics.Debug.WriteLine("PushChannelWebClient() - Setting up push channel.");
            deviceID = _deviceID;
            HttpNotificationChannel pushChannel;
            
            pushChannel = HttpNotificationChannel.Find(channelName);

            if (pushChannel == null) // If we didn't find our push channel
            {
                System.Diagnostics.Debug.WriteLine("PushChannelWebClient() - Push channel not found, setting up new one.");
                pushChannel = new HttpNotificationChannel(channelName, "my.server.com");

                pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
                pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);
                pushChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(PushChannel_ShellToastNotificationReceived);

                pushChannel.Open();

                pushChannel.BindToShellToast();
                pushChannel.BindToShellTile();
            }
            else // One already exists, but lets make sure we have an updated URI...
            {
                System.Diagnostics.Debug.WriteLine("PushChannelWebClient() - Push channel found...");
                pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
                pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);
                pushChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(PushChannel_ShellToastNotificationReceived);
            }
        }

        void PushChannel_ChannelUriUpdated(object sender, NotificationChannelUriEventArgs e)
        {
            Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        System.Diagnostics.Debug.WriteLine("Inside 'PushChannel_ChannelUriUpdated()' - " + DateTime.Now);
                        MainPage.s.PushURISetting = e.ChannelUri.ToString();
                        httpService.UpdatePush(deviceID, e.ChannelUri.ToString()); // this just sends the uri to my server for storage...
                    });
        }

        void PushChannel_ErrorOccurred(object sender, NotificationChannelErrorEventArgs e)
        {
            ThreadPool.QueueUserWorkItem(_ =>
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        MessageBox.Show(String.Format("Error setting up your push channel. There may be too many apps utilizing push.\n\nIn the meantime, notifications will not work. =(\n\nError is:\n" + e.Message));
                    });
            });
        }

Any help would be greatly appreciated!  I've been developing on a Windows 8 machine using VS2012...it is setup for Windows Phone 7.1...and I've been testing on both a Lumia 900 (WP7) and the 920 (WP8).

Thanks in advanced!

Replies

Eric Fleck on Wed, 19 Jun 2013 16:55:02


Is the problem happening on just on your two test Phones?  ... or does it also happen if you use the emulator?

If it only happens with the phones, have you tried restarting the phone?  (Power off and back on.)

I also notice you are using a ServiceName in your channel open.  (Authenticated Push)  ... How long has it been since you uploaded the corresponding certificate to dev center?

Dutton Designs on Wed, 19 Jun 2013 18:14:27


Hey Eric,

Thanks for the response.  Yes, I've tried in an emulator as well to no avail.  I've restarted both phones and even uninstalled apps that use push just in case it was a channel issue.  One phone (the 900) is bare-bones with hardly anything on it since it's not my daily driver.

Yes, I do have the cert published as well on my server (secure.duttonbiz.com)...which is the same server/url that is sending the notifications to the phone.

Like I said, this code has been working fine for a while and then the past week just simply won't work.

Thanks.


Eric Fleck on Wed, 19 Jun 2013 20:07:52


What have you done do diagnose the issue so far?

Have you tried any of the basic push notification samples...like the Toast Notification Sample?

... to determine if the problem is related to your project vs. your general network environment.

Dutton Designs on Wed, 19 Jun 2013 20:09:33


I've started new project and just simply copied the code...I've started new projects and copied the sample code and both have had the same effect...on the emulator and on my devices.

Eric Fleck on Wed, 19 Jun 2013 23:30:17


Ok, but ... a test with a public code sample that gives us a common frame of reference.  ...pass or fail it's a quick way cut out a lot of unknowns.

For example: if the code sample also fails then it's probably something lower level, i.e. in the network communications.  if the sample code works then we can reduce the investigation to the differences between the sample and your application.

Dutton Designs on Wed, 19 Jun 2013 23:57:20


Hello Eric,

I just downloaded the Toast Sample you linked to...deployed it to my 920 and still the same error is popping up.  Just tried it on another computer as well.

The exact error in the popup message is :

"A push notification ChannelOpenFailed error occurred. The channel does not exist, but could not be opened. Try opening the channel again. (-2129589901) 0"

Oh, and I've tried my code (mentioned above) at home and at work.  The sample I just tried is here at home...I have no firewall and I just tried again with my wifi turned off.

Eric Fleck on Thu, 20 Jun 2013 14:21:54


It sounds like it may be a regional problem... but it's also possible that there is more than one cause for the failure.  (I'm having trouble coming up with a [convincing] single failure cause which accounts every test scenario you describe.)

To verify, the failure rate is 100% in all the configurations you have tested... is that correct?

Do you get the error quickly, just a few seconds, or after a longer delay, 30+ seconds? 

Is the behavior identical across all test configurations? 
(Subtle differences may give important clues.)

Dutton Designs on Thu, 20 Jun 2013 19:34:15


Hey Eric,

As of yesterday, Yes, failure was 100% across all scenarios.  But today, I've noticed that when i download my app from the marketplace, it works sporadically...sometimes it will give the error mentioned above or it may work...right now it has been about 50/50 through out the day.  But, I still get the error consistently through deploying to the emulator or to the phone from visual studio on both computers...???!...now I'm really confused.

Thanks for your help.

----EDIT---

I forgot to mention that even though I'm not getting an error all the time when I use the downloaded app from the marketplace, I still can't send a notification to the phone via my service (secure.duttonbiz.com).  I either get a success response from Microsoft servers or a 404 response...but even with the 'success', the phone does not do anything.

Dutton Designs on Sat, 22 Jun 2013 21:01:40


Hello Eric,

Is there anything else that I can give you that would help?

Here is the code on my main page that calls the PushChannelWebClient().

if (s.SettingPushGood == false) // if there was an error for some reason, close the PushChannel and try again.
  new PushChannelWebClient(); // close the push channel

if (s.SettingUsePush) // User chose to enable push
  new PushChannelWebClient(deviceID); // try and open a push channel

This is driving me crazy!  I've tried rebooting my phone multiple times, uninstalling apps that use push etc.

I'm in the US (Maine)...are others here having a similar issue?

Thanks.

Sean


Eric Fleck on Mon, 24 Jun 2013 18:10:01


What kind of cellular coverage do you have in the areas you've tested?
(2G, 3G, 4G, Edge, etc...?)

For WiFi and/or wired (emulator) networks... what kind of Internet connection do you have? 
(dialup, cable, ADSL, etc...)

In addition to people having a similar issue... are there any people in your area for whom Push Notification is working just fine?  
The differences between working and not working case may provide some clue.

Russell P Archer on Tue, 20 Aug 2013 14:01:36


Hi,

Was there any kind of resolution to this issue? I've just started seeing the same thing!

I've got two physical devices - a Lumia 920 and a Lumia 520. My code is basically the same as given above, except that it uses the throttled (500 notification limit) MPNS service.

On the 920 (and three different instances of an emulator) the same code works fine. On the 520, the code worked just fine for about 2 months, and has just stopped working. I always get the error after calling Open() on the HttpNotificationChannel.

Very weird indeed!

Any clues as to what might be happening would be very much appreciated.

Russell Archer

Eric Fleck on Tue, 20 Aug 2013 17:21:13


Hi Russel,

  What error do you get when calling Open?

  Is your 520 low on storage or have battery saver turned on?

Russell P Archer on Wed, 21 Aug 2013 09:03:03


Hi Eric

Many thanks for your reply.

I always get the following error in the NotificationChannelErrorEventArgs argument passed to the HttpNotificationChannel.ErrorOccurred handler:

ErrorType = ChannelOpenFailed
Message = The channel does not exist, but could not be opened.  Try opening the channel again.
Error Code = -2129589901

Thanks for your suggestion re low storage (there's 1.6 GB free) and battery saver (it's off).

FYI, I'm using the MPNS to send raw notifications from Azure mobile services, so the client app (which is WP8-only) is getting the channel uri from MPNS and then sending it to my mobile services SQL database.

Here's the code I'm using - the call to Open() always results in the ErrorOccurred() handler being invoked:

public void Connect()
{
    try
    {
        // Before creating a new channel uri, see if we've previously been registered with the MPNS
        _httpNotificationChannel = HttpNotificationChannel.Find(ChannelName);
        if (_httpNotificationChannel == null)
        {
            // Request a new channel uri from the MPNS
            _httpNotificationChannel = new HttpNotificationChannel(ChannelName);
            SubscribeToChannelEvents();
            _httpNotificationChannel.Open();
        }
        else
        {
            // The channel is already open, just re-register for events
            ChannelUri = _httpNotificationChannel.ChannelUri; // Restore the previous channel uri
            SubscribeToChannelEvents();
        }
    }
    catch (Exception ex)
    {
	Logger.Log(ex, new StackFrame(0, true));
    }
}

private void SubscribeToChannelEvents()
{
    _httpNotificationChannel.ChannelUriUpdated += OnChannelUriUpdated;
    _httpNotificationChannel.HttpNotificationReceived += OnHttpNotificationReceived;
    _httpNotificationChannel.ErrorOccurred += OnChannelErrorOccurred;
    _httpNotificationChannel.ConnectionStatusChanged += OnConnectionStatusChanged;
}

It's a really weird issue ... kind of like MPNS has suddenly "blacklisted" the device!

This code has been working perfectly for several months, and continues to work on my 920 and the emulator. Things I've tried to resolve the issue are:

  • Tried calling Open() again (like the error msg suggests) - same result as initial call to Open()
  • Reboot the device (after shutting down and removing/replacing battery)
  • Uninstall, reboot, then reinstall the app
  • Tried with WiFi on and off
  • Turned Bluetooth off
  • Tried changing the ChannelName property from "RoundUpMPNS" to something else

I'm a bit stuck with this one, so I really appreciate you trying to help!

Russell

EDIT: I just reset (to factory settings) the 520 device ... and now everything is working just fine again. I decided to do this because other apps were behaving strangely, plus the device suddenly lost track of date and time.

So, sorry to have wasted your time, I think I'll put this down to some unknown issue that was resolved by a reset, rather than a genuine issue with the MPNS.

Very many thanks for your help anyway!

Russell



Eric Fleck on Wed, 21 Aug 2013 14:43:29


Do you have Internet Sharing option enabled in settings?

Do you have the same carrier / data plan for your 520 as the 920?

Is the 520 devices Date and Time set correctly?

Look in Settings -> Applications -> background tasks ...
   Do you see your app listed there?  ...if so, does it say "blocked" or "allowed"?
   How many apps are listed there?
   > Tap on "Advanced" button at the bottom of the list...
      How many apps are listed in this list?

The only other thing that comes to mind is the lower memory limit on the 520...
  Have you modified your app recently?
  Can you think of anything which might have increased the memory load at the time when <channel>.Open is called?

Russell P Archer on Thu, 22 Aug 2013 10:37:02


Thanks for the additional ideas Eric.

I think the problem (which I should have spotted earlier) was that, as you suggest the DATE/TIME was NOT correctly set. I think that must have been at the root of the problem - duh, should have spotted that sooner!

Anyway, many thanks once again for all your help!

Russell

Systempuntoout on Mon, 13 Jan 2014 15:16:28


Hi there,

I got this error (-2129589901) a month ago and had tried all the solutions listed above.. I had to hard-reset the device (Lumia 720) and it started to work again.

Today I got this error again on another device (HTC 8S).

This problem affects the entire Push Notification stack and it affects all the application installed; I've tried to use WhatsApp and I can't receive any tile notification.

We are publishing our application in Production in few days, and this error looks scary because it seems there's no way out .

We are Enterprise customer and we are available to make some test if you want.

Could you please help us?

Thanks

Michele


Eric Fleck on Mon, 13 Jan 2014 19:32:51


What type of network connections do you have on that phone?

For cellular networks, is Data connection enabled?  ...what about for roaming?

For WiFi, does your networks internet gateway enforce any filters or packet inspection?

Are you able to connect to internet resources from the same phone?

Systempuntoout on Mon, 13 Jan 2014 21:18:29


Hi Eric,

I can connect to Internet without any problem, Date and Time are set correctly, battery 90% up, battery saver is off.

  • Data connection: enabled
  • Wifi: disabled
  • Roaming: disabled

We are using unauthenticated push notification at the moment.

One thing to note:

this morning, I found the cell dead with the battery flat; after a quick recharge, I tested the app and started to get that nasty error.

So, as you already said, it could be related in some way with the wrong date/time the phone restarted leaving the Notification Stack in a faulty lethal status (ChannelUri: null - Status: connected).

Thanks for your support

Michele





Eric Fleck on Tue, 14 Jan 2014 15:00:46


It could be carrier related... perhaps a bad DNS entry or some other configuration preventing the device from communicating with the push service.

Are you able to test on a WiFi network with a direct connection to the internet?
...If so, try temporarily disabling the cellular data connection to force the service to use WiFi and see if it starts working again.

Systempuntoout on Tue, 14 Jan 2014 16:41:41


I've tried disabling Data connection and enabling WiFi with a direct connection, same error.

We have several devices, using the same kind of data plan, that are working without any problem.

Any further suggestion?

thanks

Michele

Eric Fleck on Tue, 14 Jan 2014 18:31:56


Did you try soft-reset of the HTC device?  (i.e. fully Power down and then turn back on.)

Also I seem to recall some people reporting success after uninstalling certain other apps on their device.

Systempuntoout on Tue, 14 Jan 2014 21:03:38


Hi Eric,

I will try the soft-reset tomorrow; I have discharged the phone again but the problem persists.

There are no apps installed beside Whatsapp (installed to test the faulty state of the Notification Stack).

Thanks

Michele

Systempuntoout on Wed, 15 Jan 2014 10:06:55


I have tried also to soft-reset  but the problem is still there.

Can't you inspect something from your side if I tell you my DeviceId?

Thanks

Michele

 

Eric Fleck on Wed, 15 Jan 2014 23:41:54


Can't you inspect something from your side if I tell you my DeviceId?

 

I don't know but I'll see if I can find out.

MultiexpoVigo on Fri, 14 Feb 2014 18:54:59


I'm getting this issue too (channelopenfailed error). This is my scenario:

  • Nokia Lumia 820 developer device.
  • Preview for developers enabled.
  • Windows Phone 8 GDR3 & Nokia Black firmware update installed.
  • Only the app that i'm developing is failing to open the channel. All other apps getting notifications normally on this device.
  • App only fails on this device, emulator works fine with same xap, another real devices (beta testers) works fine with same xap.
  • Code is copied/pasted from public documentation sample.
  • App is targetted to Windows Phone 7.1 (compatible with 7.1,7.5, 7.8 and 8.0).
  • Compiled with VS 2012 Express for Windows Phone 8, with Windows Phone 8 SDK.
  • Tried to uninstall/reboot/reinstall App.
  • Tried to change product ID, channel name and resetting App.
  • Service name using certified server (on emulator works fine getting https channel uri).
  • No battery problems (connected via USB for debug) or storage problems (2,95 GB free). No problems with date or time (automatic - CET +1).
  • Connected by WiFi or 3G (H+) with same results. Internet connection working.

It seems there aren't problems in code since it works ok on another devices or emulator. Looks like there were a problem not specific to App, but to debugging in this device, because creating another project with different product id, publisher, channel name and without service name gets same issue in this device with getting channel uri.

Any idea on what's happening here or some way to take to get more information?

Is there any way to get the really exception details behind "ChannelOpenFailed" error (or stack trace or something), and what's causing it in this case (that maybe same cause for another issues exposed on this thread)?



we_develop on Sat, 22 Feb 2014 08:45:43


Hi,

I have exactly the same problem. On some customer devices it does not work.

@Microsoft: Dear Microsoft, why do you still have so many problems with with the whole push notification thing since the initial release in 2010? It's a shame that you are not able to document all the prerequisites which must be met for a working push channel!

Bye,

Sebastian

6号楼207 on Fri, 01 Aug 2014 04:12:07


hey,guy,I have met this problem now,and I tried every methods mentioned above,including reseting my phone.But none is effective,could you please tell me how you resolved it?Thanks very much!