Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Specified argument was out of the range of valid values" when starting broker #640

Open
stu60610 opened this issue Mar 8, 2016 · 4 comments

Comments

@stu60610
Copy link

stu60610 commented Mar 8, 2016

What version of PushSharp are you using?

PushSharp v3.0.1.0

Describe your issue:

I'm trying to send an APNS notification, it works fine in Console Program. But when I try to use it on my ASP.NET website and call the function "broker.Start();", the broker just can't start. And Got a exception like this:

"Specified argument was out of the range of valid values. Parameter name: creationOptions"

Hope someone can help, thanks.

@Redth
Copy link
Owner

Redth commented Mar 9, 2016

I'm really not sure if this is entirely related to PushSharp... I don't have any methods with that parameter name, and not really sure how you would have got the exception.

You'll need to provide a full stack trace at this point.

@abhamid
Copy link

abhamid commented May 29, 2016

I also get this issue at my Production Server. Here is the stack trace.

Specified argument was out of the range of valid values.
Parameter name: creationOptions

Source Error:

// Start the broker
apnsBroker.Start();

Stack Trace:
[ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: creationOptions]
System.Threading.Tasks.Task.TaskConstructorCore(Object action, Object state, CancellationToken cancellationToken, TaskCreationOptions creationOptions, InternalTaskOptions internalOptions, TaskScheduler scheduler) +3556894
System.Threading.Tasks.Task..ctor(Object action, Object state, Task parent, CancellationToken cancellationToken, TaskCreationOptions creationOptions, InternalTaskOptions internalOptions, TaskScheduler scheduler) +88
System.Threading.Tasks.Task1..ctor(Func1 valueSelector, Task parent, CancellationToken cancellationToken, TaskCreationOptions creationOptions, InternalTaskOptions internalOptions, TaskScheduler scheduler) +110
System.Threading.Tasks.Task1.StartNew(Task parent, Func1 function, CancellationToken cancellationToken, TaskCreationOptions creationOptions, InternalTaskOptions internalOptions, TaskScheduler scheduler, StackCrawlMark& stackMark) +86
System.Threading.Tasks.TaskFactory.StartNew(Func1 function, CancellationToken cancellationToken, TaskCreationOptions creationOptions, TaskScheduler scheduler) +119 PushSharp.Core.ServiceWorker1.Start() in D:\AirFare\PushSharp-master\PushSharp-master\PushSharp.Core\ServiceBroker.cs:161
PushSharp.Core.ServiceBroker1.ChangeScale(Int32 newScaleSize) in D:\AirFare\PushSharp-master\PushSharp-master\PushSharp.Core\ServiceBroker.cs:119 PushSharp.Core.ServiceBroker1.Start() in D:\AirFare\PushSharp-master\PushSharp-master\PushSharp.Core\ServiceBroker.cs:67
SendMessage.btnSend_Click(Object sender, EventArgs e) in d:\Sites\Luchtmacht_With_Push\SendMessage.aspx.cs:70
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563

@CoolDixon
Copy link

I had the same issue with PushSharp 4.0

After upgrading .NET from .4.0 to 4.5 the problem disappeared

@nmduc073
Copy link

nmduc073 commented Dec 9, 2017

I have the same issue with PushSharp 4.0.

Can anyone help me, please?
static void Test()
{
// Configuration (NOTE: .pfx can also be used here)
var config = new ApnsConfiguration(ApnsConfiguration.ApnsServerEnvironment.Sandbox,
"Certificates_moi.p12", "123456");

        // Create a new broker
        var apnsBroker = new ApnsServiceBroker(config);

        // Wire up events
        apnsBroker.OnNotificationFailed += (notification, aggregateEx) =>
        {

            aggregateEx.Handle(ex =>
            {

                // See what kind of exception it was to further diagnose
                if (ex is ApnsNotificationException)
                {
                    var notificationException = (ApnsNotificationException)ex;

                    // Deal with the failed notification
                    var apnsNotification = notificationException.Notification;
                    var statusCode = notificationException.ErrorStatusCode;

                    Console.WriteLine("Apple Notification Failed: ID={apnsNotification.Identifier}, Code={statusCode}");

                }
                else
                {
                    // Inner exception might hold more useful information like an ApnsConnectionException			
                    Console.WriteLine("Apple Notification Failed for some unknown reason : {ex.InnerException}");
                }

                // Mark it as handled
                return true;
            });
        };

        apnsBroker.OnNotificationSucceeded += (notification) =>
        {
            Console.WriteLine("Apple Notification Sent!");
        };

        // Start the broker
        apnsBroker.Start();

        //foreach (var deviceToken in MY_DEVICE_TOKENS) {
        //    // Queue a notification to send
        //    apnsBroker.QueueNotification (new ApnsNotification {
        //        DeviceToken = deviceToken,
        //        Payload = JObject.Parse ("{\"aps\":{\"badge\":7}}")
        //    });
        //}
        // Queue a notification to send
        apnsBroker.QueueNotification(new ApnsNotification
        {
            DeviceToken = "966661b0ee5860a70b2e095c63bbb9a3c035b6779ccfc54bf029b27f88f882ef",
            Payload = JObject.Parse("{\"aps\":{\"badge\":7}}")
        });
        // Stop the broker, wait for it to finish   
        // This isn't done after every message, but after you're
        // done with the broker
        apnsBroker.Stop();
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants