Can't make first connection — Connection Canceled

Hi all,

We’re trying to use SBUIKit for a project, and we’re keeping constantly getting “Connection was canceled” errors in the console.

We’re instantiating the SDK in the AppDelegate, and keeping track of its state using Combine. When the completionHandler for the SDK is called, we set the state to ready and as soon as that happens.

var statePublisher: AnyPublisher<SendbirdSDKState, Never> { $sendbirdSDKState.eraseToAnyPublisher() }

func setupSendbirdSDK() {
        SBUMain.setLogLevel(.all)
        
        SBUMain.initialize(applicationId: APP_ID) {
            
        } completionHandler: { [weak self] error in
            if let error = error {
                self?.sendbirdSDKState = .error(error: error)
            } else {
                self?.sendbirdSDKState = .ready
            }
        }
    }

Seemingly, this all works out, as we do receive the .ready state from the completionHandler. However, when we try to connect in our root ViewController, which we do like so:

    private func handleSDKReady() {
        SBUGlobals.CurrentUser = SBUUser(userId: userId, nickname: "Tester")
        
        SBUMain.connect { [presenter] user, error in
            if let error = error {
                print(error)
            } else if user != nil {
                // Do some stuff
            }
        }
    }

We get stuck in an infinite loop of Connection was canceled errors, along with notices that the user was nil. What’s interesting is that we did try plugging the same appID and userID into the sample app, and it was working fine, but we can’t really tell where we are going wrong. Here’s a sample of our logs:

🎨SBULog 📕Error Main [2021-12-27 18:06:23.301 SBUMain:connectAndUpdates(completionHandler:):126] [Failed] Connection to Sendbird: Connection was canceled
Error Domain=Connection was canceled Code=800102 "Connection was canceled" UserInfo={NSLocalizedDescription=Connection was canceled}
2021-12-27 18:06:23.379019+0100 Open Up[44068:724757] [boringssl] boringssl_metrics_log_metric_block_invoke(151) Failed to log metrics
2021-12-27 18:06:23.402874+0100 Open Up[44068:724661] Connection not set before response is received, failing task
2021-12-27 18:06:23.403094+0100 Open Up[44068:724661] Task <64B0A8A9-5336-44D0-8A3C-2410752569B2>.<1> finished with error [-1005] Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost."

We’ve tried a few things but are not sure how to proceed.

We solved it! In case someone is having the same issues: a package we used called “WormHoly” interfered somehow with the Sendbird SDK’s ability to connect. Removing it makes the above code work.