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

[Solved] System.ArgumentException in ApnsConnection.Send() #1

Open
IvoryRubble opened this issue Sep 18, 2019 · 3 comments
Open

[Solved] System.ArgumentException in ApnsConnection.Send() #1

IvoryRubble opened this issue Sep 18, 2019 · 3 comments

Comments

@IvoryRubble
Copy link
Owner

IvoryRubble commented Sep 18, 2019

What version of PushSharp are you using?

Describe your issue:

System.ArgumentException in ApnsConnection.Send() happens sometimes when call apnsBroker.QueueNotification(apnsNotification); several thousends times in foreach loop
This happens likely because ApnsConnection.notifications Queue is not thread-safe

What are the steps required to reproduce this issue?

Please provide any Exception Stack Traces

System.ArgumentException: Source array was not long enough. Check the source index, length, and the array's lower bounds.
Parameter name: sourceArray
   at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length, Boolean reliable)
   at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length)
   at System.Collections.Generic.Queue`1.SetCapacity(Int32 capacity)
   at System.Collections.Generic.Queue`1.Enqueue(T item)
   at PushSharp.Apple.ApnsConnection.Send(CompletableApnsNotification notification)
   at PushSharp.Apple.ApnsServiceConnection.Send(ApnsNotification notification)
@IvoryRubble
Copy link
Owner Author

IvoryRubble commented Sep 18, 2019

One suggestion is properly lock notifications Queue in ApnsConnection.
Redth#672 (comment)
#2

@IvoryRubble
Copy link
Owner Author

IvoryRubble commented Sep 18, 2019

Another solution is replace notification Queue to ConcurrentQueue
Redth#770

@IvoryRubble
Copy link
Owner Author

Published nuget package with fix for this issue: https://www.nuget.org/packages/Actonica.PushSharp.Core/
This package deploys pull-request #2

@IvoryRubble IvoryRubble reopened this Sep 19, 2019
@IvoryRubble IvoryRubble changed the title System.ArgumentException in ApnsConnection.Send() [Solved] System.ArgumentException in ApnsConnection.Send() Sep 19, 2019
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

No branches or pull requests

1 participant