Not Working EventHandlerForClass

I have registered EventHandlerForClass. My App running 24*7 hr and updating content from backedless.

It was updating content instantly for few days but suddenly stop working. Could you please let me know there is any timeline for listner

Hello @Vinod_Sahu

Could you please share your App ID?

Regards,
Viktor

App Id ; 91409DD6-D93D-AF1D-FF8F-67D79ADE4B00

Hello @Vinod_Sahu,

Could you please provide a simple code sample that reproduces your issue because we cannot reproduce this problem.

Regards,
Olha

let eventListner = Backendless.shared.data.of(ConciergeServices.self).rt

func registerListner() -> Void {

    _ = eventListner?.addCreateListener(responseHandler: { (create) in
        
        if let model = create as? ConciergeServices{
        
            self.allConciergeService.append(model)
        }
        
    }, errorHandler: { (error) in
        
    })
    
    _ = eventListner?.addUpdateListener(responseHandler: { (update) in
        
        if let model = update as? ConciergeServices{
            
            self.allConciergeService = self.allConciergeService.map { (service) -> ConciergeServices in
                
                if service.objectId == model.objectId{
                    
                    return model
                }
                
                return service
            }
        }
        
    }, errorHandler: { (error) in
        
    })
    
    _ = eventListner?.addDeleteListener(responseHandler: { (delete) in
        
        if let model = delete as? ConciergeServices{
            
           self.allConciergeService.removeAll { (service) -> Bool in
                
                return service.objectId == model.objectId
           }
        }
        
    }, errorHandler: { (error) in
        
    })
}

Hello @Vinod_Sahu,

I’ve simplified your code a little, just to print the logs when listeners are triggered and everything works fine for me in your app:

func registerListner() -> Void {
    _ = eventListner?.addCreateListener(responseHandler: { (create) in
        if let model = create as? ConciergeServices {
            print("CREATE Result: \(model)")
        }
    }, errorHandler: { (error) in
        print("CREATE Error: \(error.message ?? "")")
    })
        
    _ = eventListner?.addUpdateListener(responseHandler: { (update) in
        if let model = update as? ConciergeServices {
            print("UPDATE Result: \(model)")
        }
    }, errorHandler: { (error) in
        print("UPDATE Error: \(error.message ?? "")")
    })
        
    _ = eventListner?.addDeleteListener(responseHandler: { (delete) in
        if let model = delete as? ConciergeServices {
            print("DELETE Result: \(model)")
        }
    }, errorHandler: { (error) in
        print("DELETE Error: \(error.message ?? "")")
    })
}
  1. I’ve added a new record to the ConciergeServices table.
  2. I’ve updated one of the ConciergeServices table’s value.
  3. I’ve deleted that record.

All listeners triggered as expected:

Please make sure you handle the server response correctly in case this issue still appears.

Regards,
Olha

Exeption ::: Error Domain=BackendlessErrorDomain Code=0 “Reached Limit: you can not have more then 30 subscriptions per one connection”

2020-11-19 09:14:59.662032+0530 OneDenison[207:5756] [connection] nw_resolver_start_query_timer_block_invoke [C27] Query fired: did not receive all answers in time for rt3-cloud.dal01.backendless.com:443
2020-11-19 09:14:59.662512+0530 OneDenison[207:5756] [connection] nw_read_request_report [C24] Receive failed with error “Software caused connection abort”
2020-11-19 09:14:59.665455+0530 OneDenison[207:5756] [connection] nw_read_request_report [C27] Receive failed with error “Software caused connection abort”
2020-11-19 09:14:59.675340+0530 OneDenison[207:5756] Connection 26: received failure notification
2020-11-19 09:14:59.675549+0530 OneDenison[207:5756] [connection] nw_flow_add_write_request [C26.1 66.114.116.4:443 failed channel-flow (satisfied (Path is satisfied), viable, interface: en1, ipv4, dns)] cannot accept write requests
2020-11-19 09:14:59.675632+0530 OneDenison[207:5756] [connection] nw_write_request_report [C26] Send failed with error “Socket is not connected”

2020-11-19 09:21:36.932037+0530 OneDenison[219:6624] [Print] ----------applicationWillEnterForeground-----------
2020-11-19 09:21:50.909417+0530 OneDenison[219:7495] [connection] nw_read_request_report [C11] Receive failed with error “Software caused connection abort”
2020-11-19 09:21:50.910244+0530 OneDenison[219:7495] [connection] nw_read_request_report [C8] Receive failed with error “Software caused connection abort”
2020-11-19 09:21:50.915100+0530 OneDenison[219:7495] Task <85756666-EB70-4A35-976A-B29EF0B30766>.<3> HTTP load failed, 134/801147724 bytes (error code: -1005 [1:53])
2020-11-19 09:21:50.927424+0530 OneDenison[219:7495] Task <85756666-EB70-4A35-976A-B29EF0B30766>.<3> finished with error [-1005] Error Domain=NSURLErrorDomain Code=-1005 “The network connection was lost.” UserInfo={_kCFStreamErrorCodeKey=53, NSURLSessionDownloadTaskResumeData={length = 5497, bytes = 0x62706c69 73743030 d4010203 04050607 … 00000000 000014d1 }, NSUnderlyingError=0x282af9e60 {Error Domain=kCFErrorDomainCFNetwork Code=-1005 “(null)” UserInfo={NSErrorPeerAddressKey=<CFData 0x280687b60 [0x1fa304010]>{length = 16, capacity = 16, bytes = 0x100201bb3475ec530000000000000000}, _kCFStreamErrorCodeKey=53, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDownloadTask <85756666-EB70-4A35-976A-B29EF0B30766>.<3>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
“LocalDownloadTask <85756666-EB70-4A35-976A-B29EF0B30766>.<3>”
), NSLocalizedDescription=The network connection was lost., NSErrorFailingURLStringKey=https://omegaforums.net/25mbitHEVC.mp4, NSErrorFailingURLKey=https://omegaforums.net/25mbitHEVC.mp4, _kCFStreamErrorDomainKey=1}
2020-11-19 09:21:54.434048+0530 OneDenison[219:6624] [Print] File Download Progress…
2020-11-19 09:21:54.447919+0530 OneDenison[219:6624] [Print] ---------applicationDidBecomeActive------------

NOTE : I am trying to connect listener while coming in forground

Hello @Vinod_Sahu

Could you tell us if you disconnect listeners when exiting the foreground? Or do you just minimize the app and then open and subscribe again?

Regards,
Inna

Yes When moving in Background removed listener.

Could you please attach an archive with Xcode project which reproduces this issue and the steps we can follow to reproduce it.

Regards,
Olha

Can I share code here ? because its public platform

Also this is Apple TV Project

@Vinod_Sahu

Please send to this mail: olga@themidnightcoders.com

Regards,
Inna

Sure

Sent

I received your email and created the internal ticket BKNDLSS-23323 to investigate this issue as soon as possible.

Regards,
Olha

Hello @Vinod_Sahu ,

As far as I couldn’t build the project you’ve sent because of “No such module” errors, I’ve checked your AppDelegate class and recreated the listeners methods in my test project.
I’ve created 7 tables with the name fields and added the create/update/delete listeners for every class (21 listeners in total).
I have no issues with RT. I’ve added some logs to check if subscriptions a created and deleted correctly and as you see on the videos attached below - 21 listeners are created on applicationWillResignActive() and all of them are removed on applicationWillEnterForeground(). After the applicationWillResignActive() is called the 21 subscriptions are created (no more no less):

Video 1. Remove listeners with the removeAllListeners() method
Video 2. Remove listeners with the removeCreate/Update/DeleteListeners() methods

As you can see on the video everything works fine, all listeners are triggered after the applicationWillResignActive() is called.

Since there were no RT changes in Swift-SDK for a long time I only can advice you to update to the lates version of Swift-SDK (6.1.2) and check your project carefully, maybe some delays in the DispatchQueue may cause the problems with resubscriptions.

I’ll attach my working test project, maybe it could be helpful, but unfortunately I can’t help here more than this:
Test.zip (373.6 KB)

Regards,
Olha

Hello Olha,

Thank you so much for your support. I run your code on my Apple TV and still facing the issue. I have replied on personal email. Could you please run that code and let me know that is compatible with Apple TV or not.