Open RajaReddyiOS opened 5 years ago
I'm also experiencing issues with passing a background queue, but in my case directly to MQTTSession.
Using MQTTSession with the default main queue works quite well, but once in a while the UI hangs on a socket error. To alleviate this, I want to run the session on a background queue. However, this behaves completely unpredictable, with continuous disconnects and errors on newMessage, such as:
Looking through the discussion on this topic, I am really bewildered by calling the session in runloops and such. These threading details should be abstracted away. I simply want the client to perform all networking on the background. I don't mind wrapping any code performed in newMessage in a DispatchQueue.main block.
let QUEUE = DispatchQueue.global(qos: DispatchQoS.QoSClass.background)
MQTTSessionManager(persistence: false, maxWindowSize: 16, maxMessages: 1024, maxSize: 64, maxConnectionRetryInterval: 60.0, connectInForeground: false, streamSSLLevel: nil, queue: QUEUE)
when i pass DispatchQueue.main its working but issue with passing background queue