React Native Chat SDK, when trying to connect, get Websocket Connection Failed error

Hi. I have 2 implementations of my app:

  1. React (web app),
  2. React Native.

My web app is connecting and fully functioning without problems. However, in React Native, when I try to connect using sb.connect(), I am getting the below errors:

API dummy call failed [SendBirdException: Request failed.]
SendBirdException: Websocket connection failed.

I’m running React Native with Expo Client & Expo CLI on my own Android device.

I’m just using the SDK called. I tried using getInstance() as well in my other SDK methods, but did not succeed.
Do I need to call sb.disconnect() in my web app? Does it have anything to do with that?
Do I need to create my own API call to the server to connect/create instances?

Here’s my code:

import Sendbird from 'sendbird';

function Connect(sbAppId, sbUserId) {

    return new Promise((resolve, reject) => {

        const sb = new Sendbird({ 'appId': sbAppId });

        sb.connect(sbUserId, (user, error) => {

            if (error) {

                reject('SendBird Connection Failed.');

            } else {

                resolve('success')

            }

        })

    })

}

export default Connect;

If “Websocket connection failed” is present, have you checked your device / simulator has internet connection?

You should move the const sb = new Sendbird({ … }) to the top and call it once.

You need to create sendbirdContext to use for react native