Skip to content

Conversation

@bvandehey
Copy link

The UrbanAirSharp library fails after 160 requests if your program creates a new instance of the UrbanAirshipGateway for each request. Due to our multi-tenant application, this is a requirement. The reason it fails is due to the static ServiceModelConfig class which contains a static reference to the HttpClient class. I have refactored the code to change ServiceModelConfig from a static class to an instance class which eliminates this issue.

@bvandehey
Copy link
Author

bvandehey commented Jun 30, 2017

Here's a simple program that replicates the failure at 160 requests:

class Program
{
    private static int count = 0;
    static void Main(string[] args)
    {
        for (int i = 0; i < 200; i++)
        {
            SendUASMessage();
        }

    }

    public static void SendUASMessage()
    {
        var client = new UrbanAirSharpGateway("{appkey}", "{secretkey");
        Audience audience = new Audience(AudienceType.Android, "{devicekey}");
        string message = "(Test Message)";
        var response = client.Push(message, null, null, null, audience);
        count++;
        Console.WriteLine(!response.Ok
                              ? $"{count} - Urban Airship Error: {response.Message}"
                              : $"{count} - {response.Message}");
    }
}

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant