Cannot re-call BeginGetRequestStream/BeginGetResponse while a previous call is still in progress.

I’m using backendless for .NET and getting that exception.

Unhandled Exception: BackendlessAPI.Exception.BackendlessException: Cannot re-call BeginGetRequestStream/BeginGetResponse while a previous call is still in progress.
at BackendlessAPI.Engine.Invoker.InvokeSync[T](String className, String methodName, Object[] args, Boolean enableUnderFlowInspection)
at BackendlessAPI.Engine.Invoker.InvokeSync[T](String className, String methodName, Object[] args)
at BackendlessAPI.Service.MessagingService.PollMessages(String channelName, String subscriptionId)
at BackendlessAPI.Messaging.Subscription.<OnSubscribe>b__0(Object c)
at System.Threading.TimerQueueTimer.CallCallbackInContext(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.TimerQueueTimer.CallCallback()
at System.Threading.TimerQueueTimer.Fire()
at System.Threading.TimerQueue.FireQueuedTimerCompletion(Object state)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
All my callbacks are running in separate threads, what could be a problem and how do I solve it?
Thank you.

Hi Dennis,

Could you please let me know what your subscription request looks like? By that I mean how you initialized the SubscriptionOptions object (if you use it) and what polling interval you used.

Regards,
Mark

I’m not using any subscription options.

Here is how do I subscribe to channel:

var messageHandler = GetResponseCallback(callback, GetBackendlessMessage, channelName);

var subscriptionHandler = new AsyncCallback<Subscription>(
subscription =>
{
SubscribedChannels.Add(channelName, subscription);
},
fault =>
{
Logger.LogError($"{fault.FaultCode} message: {fault.Message}");
});

Logger.LogInfo($“Subscribe, channel name {channelName}”);
BackendlessAPI.Backendless.Messaging.Subscribe(channelName, messageHandler, subscriptionHandler);

Did you make sure the subscription call is made only once?

Yes, I have if (!SubscribedChannels.ContainsKey(channelName)) before that code I posted above.