SessionAPIUtilities.h:176 AudioSessionGetProperty...
# ask-ai
c
SessionAPIUtilities.h:176 AudioSessionGetProperty (kMXSessionProperty_HasEchoCancelledInput) failed with error: -50 (sessionID: 0x0) I'm seeing this error while trying to setup livekit in my react native expo app (Ignite Boilerplate). We have "react-native": "0.72.10" and have setup alomost everything provided in the sample template. Any suggestions ?
t
Thanks for reaching out, Shwet. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hi there! The error
AudioSessionGetProperty (kMXSessionProperty_HasEchoCancelledInput) failed with error: -50
is related to the iOS audio session configuration. It usually points to a parameter issue when checking echo cancellation properties. The good news is, this error often doesn’t affect the core functionality. To help you out, here are some steps you can try: 1. Make sure your SDK is set up properly in your iOS AppDelegate. For example, in Objective-C:
Copy code
#import "LivekitReactNative.h"

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  [LivekitReactNative setup];
  // ... other initialization
}
2. Try testing the audio functionality in real scenarios to see if the error actually impacts performance. 3. Consider customizing the audio session configuration using
setAppleAudioConfiguration()
before connecting to a room:
Copy code
import { AudioSession } from '@livekit/react-native';

await AudioSession.setAppleAudioConfiguration({
  audioCategory: 'playAndRecord',
  audioCategoryOptions: [
    'allowBluetooth',
    'allowBluetoothA2DP', 
    'allowAirPlay',
    'defaultToSpeaker'
  ],
  audioMode: 'videoChat'
});
4. Double-check that you’re using the latest versions of
@livekit/react-native
and
@livekit/react-native-webrtc
. 5. It might also help to debug the audio session state by checking available outputs and monitoring any state changes:
Copy code
const outputs = await AudioSession.getAudioOutputs();
console.log('Available audio outputs:', outputs);
If your audio is working fine despite this message, you can usually treat this error as a harmless warning. Please feel free to reach out if you have any more questions or need further help—I’m here for you! Sources: example/ios/LivekitReactNativeExample/AppDelegate.mm | Noise & echo cancellation | LiveKit Docs
c
I see a blank screen with no agent starting to speak
t
Thanks so much for reaching out! To get to the bottom of the blank screen and the "Possible unhandled promise rejection" error you're seeing, could you please check a few things for me? • Have you called
registerGlobals()
in your app's entry point (like
index.js
)? • Did you make sure to implement the native
setup()
calls in
AppDelegate
for iOS and
MainApplication
for Android? • Are you using
AudioSession.startAudioSession()
before connecting to the room? • Would you be able to share the full error message from the promise rejection? Once we have these details, I’ll be in a much better position to help you find the right fix. Looking forward to your reply! Sources: src/index.tsx
c
console.log('Available audio outputs:', outputs); This gives me 1. 0: "default" 2. 1: "force_speaker"
t
It looks like the available audio outputs
default
and
force_speaker
show that your audio session is active and that routing options are ready to go. That’s a great start! However, the blank screen you’re seeing might still be connected to video rendering or how the connection is set up. To help us get to the bottom of this together, could you please check a few things for me? • Are you passing the correct
serverUrl
and
token
to the
LiveKitRoom
component? • Have you wrapped your components inside
LiveKitRoom
with the necessary props like
connect=true
,
audio=true
, and
video=true
? • Are you calling
AudioSession.startAudioSession()
before connecting to the room? • Would you be able to share the full error message from the "Possible unhandled promise rejection" notification? With these details, we’ll have a clearer picture of whether the issue is related to media permissions, connection setup, or rendering. I’m here to help you through this, so feel free to share whatever you find!
c
serverUrl and token are correct these are other props, but Connected to LiveKit never prints connect={true} onConnected={() => console.log("Connected to LiveKit")} onDisconnected={() => console.log("LiveKit Disconnected")} onError={(e) => console.error("LiveKit Error:", e)} onMediaDeviceFailure={(e) => console.error("Media Device Error:", e)} onEncryptionError={(e) => console.error("Encription Error:", e)} audio={true} video={false}
t
It seems like the
onConnected
callback not being triggered might be due to a connection hiccup. Let’s walk through a few things together to help get this sorted: • Make sure
registerGlobals()
is called right at the start of your app, such as in
index.js
. • Before connecting to the room, please call
AudioSession.startAudioSession()
. • Take a look at the
onError
callback for any error messages. Sometimes issues can come from invalid tokens, network troubles, or missing permissions. • Double-check that the native setup is all set up properly: • On Android: Ensure you’ve called
LiveKitReactNative.setup(this)
inside
MainApplication
. • On iOS: Make sure
[LivekitReactNative setup]
is called in
AppDelegate
. If you’ve already gone through these steps, could you please share what you’re seeing in the
onError
callback or any other logs? That info will really help us get to the bottom of this together. Sources: README.md | packages/react/src/hooks/useLiveKitRoom.ts
c
how do I make sure Room is not getting connected before AudioSession.startAudioSession(). i'm a newbee
t
To make sure the room doesn’t connect before
AudioSession.startAudioSession()
is called, you can gently control the connection flow by setting
connect
to
false
at first, and then connecting programmatically after starting the audio session. Here’s a friendly way to do it: 1. First, set
connect=false
in your
LiveKitRoom
component:
Copy code
<LiveKitRoom
  serverUrl="{serverUrl}"
  token="{token}"
  connect={false}
  onConnected={() => console.log("Connected to LiveKit")}
  onError={(e) => console.error("LiveKit Error:", e)}
  audio={true}
  video={false}
/>
1. Then, use a
useEffect
or similar logic to start the audio session and connect right after:
Copy code
import { AudioSession } from '@livekit/react-native';
import { useRef, useEffect } from 'react';

const MyComponent = () => {
  const roomRef = useRef(null);

  useEffect(() => {
    const setupAudioAndConnect = async () => {
      try {
        await AudioSession.startAudioSession();
        console.log("Audio session started");
        roomRef.current?.connect();
      } catch (error) {
        console.error("Error starting audio session:", error);
      }
    };

    setupAudioAndConnect();
  }, []);

  return (
    <LiveKitRoom
      ref={roomRef}
      serverUrl="{serverUrl}"
      token="{token}"
      connect={false}
      onConnected={() => console.log("Connected to LiveKit")}
      onError={(e) => console.error("LiveKit Error:", e)}
      audio={true}
      video={false}
    />
  );
};
This way, you’re ensuring the audio session is all set up before the room actually connects. If you’d like me to walk you through any part of this or if something isn’t clear, just let me know—I’m here to help!
c
Property 'ref' does not exist on type 'IntrinsicAttributes & LiveKitRoomProps & { children?: ReactNode; }'
t
Thanks for reaching out! The error happens because the
ref
property isn’t directly supported on the
LiveKitRoom
component. But no worries — you can use the
useLiveKitRoom
hook to manage the room instance programmatically. Here’s a friendly way to update your code: 1. First, use the
useLiveKitRoom
hook to access the room instance:
Copy code
import { useLiveKitRoom, AudioSession } from '@livekit/react-native';
import { useEffect } from 'react';

const MyComponent = () => {
  const { room, connect } = useLiveKitRoom({
    serverUrl: "{serverUrl}",
    token: "{token}",
    connect: false, // Start with connect set to false
  });

  useEffect(() => {
    const setupAudioAndConnect = async () => {
      try {
        await AudioSession.startAudioSession();
        console.log("Audio session started");
        connect(); // Programmatically connect to the room
      } catch (error) {
        console.error("Error starting audio session:", error);
      }
    };

    setupAudioAndConnect();
  }, [connect]);

  return (
    <LiveKitRoom
      room={room}
      onConnected={() => console.log("Connected to LiveKit")}
      onError={(e) => console.error("LiveKit Error:", e)}
      audio={true}
      video={false}
    />
  );
};
This way, you’ll be managing the room instance smoothly and connecting right after starting the audio session. If you have any questions or need a hand with anything else, just let me know — I’m here to help!
c
SessionAPIUtilities.h:176 AudioSessionGetProperty (kMXSessionProperty_HasEchoCancelledInput) failed with error: -50 (sessionID: 0x0) Audio session started 'Available audio outputs:', [ 'default', 'force_speaker' ] Running surface LogBox ({ initialProps = { }; rootTag = 81; }) Failed to mount LogBox within 1s nw_connection_copy_connected_local_endpoint_block_invoke [C342] Connection has no local endpoint
t
It looks like you're encountering the error
nw_connection_copy_connected_local_endpoint_block_invoke Connection has no local endpoint
, which usually points to a network connectivity challenge, often involving WebRTC or ICE (Interactive Connectivity Establishment) negotiation. Let’s work through some steps together to get this sorted out: 1. First, please make sure that
registerGlobals()
is being called right at your app's entry point, like in
index.js
. 2. Next, double-check that your network supports WebRTC connections. It can be helpful to try switching between different networks, such as WiFi and cellular, to see if a firewall or VPN might be causing any restrictions. 3. Take a look at your ICE server configuration as well. Confirm that your LiveKit server is set up correctly with the necessary STUN/TURN servers. 4. Running some connection diagnostics can really shed light on the issue. Tools like
checkWebRTC()
,
checkTURN()
, and
checkWebsocket()
are great for spotting network-level hiccups. 5. Also, double-check your SDK setup in the native files: • For Android: Make sure you call
LiveKitReactNative.setup(this)
inside
MainApplication
. • For iOS: Ensure
[LivekitReactNative setup]
is called in
AppDelegate
. If you’re still running into trouble after these checks, could you let me know if you’re on a corporate network or using a VPN? Also, any extra logs or error messages you can share would be super helpful to pinpoint what’s going on. I’m here to help you get this resolved! Sources: README.md | Documentation/CallGuide.md
c
syntax for this please 1. Running some connection diagnostics can really shed light on the issue. Tools like
checkWebRTC()
,
checkTURN()
, and
checkWebsocket()
are great for spotting network-level hiccups.
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!
c
Possible unhandled promise rejection (id: .... I'm not able to read full error, but it happens as soon the component renders with connect true
Help