AgoraIO-Extensions / react-native-agora

React Native around the Agora RTC SDKs for Android and iOS agora
https://www.agora.io
MIT License
620 stars 227 forks source link

Not receiving audio from Web SDK after v4.x upgrade #756

Closed jfbourne closed 8 months ago

jfbourne commented 8 months ago

Describe the bug Unable to receive audio from WebSDK after upgrading to RN Agora v4.x

To Reproduce

  1. Create a Web Client (agora-rtc-sdk-ng 4.20.0 or v3X)
  2. Set a channel, Join the channel, and publish a local track audio track (as host or any other)
  3. Create a React Native Client v4.x (iOS and/or Android)
  4. Join the channel created using the Web Client SDK
  5. Speak through the Web Client mic Expected behavior The React Native Clients v4.x (Android and iPhone) should receive the audio from the Web Client SDK but audio does not come through.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information): WEB: Initializing AgoraRTC client v4.20.0 build: v4.20.0-0-g334e514b-dirty(12/8/2023, 3:48:29 PM), mode: live, codec: vp9 React Native: react-native-agora: 4.2.6

Smartphone (please complete the following information):

Additional context If the React Native Client is v3.x it it can receive audio from the Web Client SDK (v3.x and v4.x)l; however, after upgrading the RN Clients to v4.x, they are not able to receive audio from the Web Client SDK (v3x or v4.x). Communication between RN Clients (v3.x and v4.x) works.

NOTE: I only use the audio portion for "live" streaming to large audiences (10+ listeners)

guoxianzhe commented 8 months ago

@jfbourne change the Reproduce step 3 client to https://github.com/AgoraIO-Extensions/react-native-agora/tree/main/example , is that work on the demo?

jfbourne commented 8 months ago

@guoxianzhe after many hours of troubleshooting I narrowed down the issue to be related to joinChannelWithUserAccount and the RtcTokenBuilder.buildTokenWithAccount. Let me explain

It appears that it can successfully join the call as you can see below

Screenshot 2023-12-19 at 4 04 07 PM

However; it does not receive any audio if I join with joinChannelWithUserAccount and a token generated by RtcTokenBuilder.buildTokenWithAccount

The only time it will receive audio is if I generate a token with RtcTokenBuilder.buildTokenWithUid and join with joinChannel

This behavior is present in my app as well as the example app as you referenced above ONLY for audio (using live streaming) sent using Agora Web SDK 4.20.0 as a 'host' and the React Native Clients joining as listener audience.

guoxianzhe commented 8 months ago

@jfbourne If you use joinChannelWithUserAccount, the Agora Web SDK 4.20.0 side should also use string uid too.

eg:

let client = AgoraRTC.createClient();
client.join(appid,channel,token,'12345') // '12345' is uid
jfbourne commented 8 months ago

@guoxianzhe Thanks.. just a few hours before your reply I came across a warning message here describing exactly what you said

Attention: To ensure smooth communication, use the same parameter type to identify the user. For example, if a user joins the channel with a user ID, then ensure all the other users use the user ID too. The same applies to the user account. If a user joins the channel with the Agora Web SDK, ensure that the ID of the user is set to the same parameter type.

https://api-ref.agora.io/en/voice-sdk/react-native/4.x/API/class_irtcengine.html#api_irtcengine_joinchannel2

Thank you that solved my issue.