It’s a couple of days since I try to connect in any way with the Agora.io SDK in Unity.
I’m new to Agora and I just started to learn how to use it, I tried basically ALL tutorials to learn how to use the SDK and I cannot make it work in any way.
Here are the steps I did:
- Created a new Agora account
- Created new appID (tried both with and without the token)
- Created a new empty project in unity
- Imported from the asset store the SDK
- Set the appID and if asked the token (depends if the project was the empty project or the example project on GitHub)
- Tried to connect/join the channel
- Get errors like:
Warning code:104 msg:lookup channel timed out (server no response)
Those are the tutorial I followed:
- https://www.youtube.com/watch?v=uxIQOZr6RiU
- https://www.agora.io/en/blog/agora-video-sdk-for-unity-quick-start-programming-guide/
- https://docs.agora.io/en/Video/start_call_unity?platform=Unity
- https://docs.agora.io/en/Video/run_demo_video_call_unity?platform=Unity
- https://medium.com/agora-io/how-to-create-a-video-chat-app-in-unity-26780b479a78
- https://www.agora.io/en/blog/how-to-embed-group-video-chat-in-your-unity-games/?utm_source=twitter&utm_medium=social&utm_campaign=embed-group-videochat-into-unity
This is really frustrating, I really don’t know what else I can do. Also, I tried to open the firewall ports on my PC or disable the antivirus with no luck. (with the same version of Unity in another project I use Mirror and it works, nothing is blocking it)
Here the tutorial code I followed if it could be useful:
using agora_gaming_rtc;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace Agora_tutorial
{
public class AgoraChat : MonoBehaviour
{
public string AppID;
public string ChannelName;
VideoSurface myView;
VideoSurface remoteView;
IRtcEngine mRtcEngine;
void Awake()
{
SetupUI();
}
void Start()
{
SetupAgora();
}
void SetupUI()
{
GameObject go = GameObject.Find("MyView");
myView = go.AddComponent<VideoSurface>();
go = GameObject.Find("JoinButton");
if (go != null)
{
Button objectButton = go.GetComponent<Button>();
objectButton.onClick.AddListener(Join);
}
go = GameObject.Find("LeaveButton");
if (go != null)
{
Button objectButton = go.GetComponent<Button>();
objectButton.onClick.AddListener(Leave);
}
}
void SetupAgora()
{
mRtcEngine = IRtcEngine.GetEngine(AppID);
// Callbacks for the local user
mRtcEngine.OnJoinChannelSuccess = OnJoinChannelSuccessHandler; // When the local user joins the channel successfully
mRtcEngine.OnLeaveChannel = OnLeaveChannelHandler; // When the local user leaves the channel
// Callbacks for the remote users
mRtcEngine.OnUserJoined = OnUserJoined; // When the remote user joins the channel
mRtcEngine.OnUserOffline = OnUserOffline; // When the remote user leaves the channel
}
public void Join()
{
Debug.Log($"Joining");
mRtcEngine.EnableVideo();
mRtcEngine.EnableVideoObserver();
myView.SetEnable(true);
mRtcEngine.JoinChannel(ChannelName, "", 0);
}
public void Leave()
{
Debug.Log($"Leaving");
mRtcEngine.LeaveChannel();
mRtcEngine.DisableVideo();
mRtcEngine.DisableVideoObserver();
}
private void OnJoinChannelSuccessHandler(string channelName, uint uid, int elapsed)
{
// can add other logics here, for now just print to the log
Debug.LogFormat("Joined channel {0} successful, my uid = {1}", channelName, uid);
}
void OnLeaveChannelHandler(RtcStats stats)
{
// Turn off the rendering, otherwise, the last frame of the camera video will stay on the RawImage.
myView.SetEnable(false);
if (remoteView != null)
{
remoteView.SetEnable(false);
}
}
void OnUserJoined(uint uid, int elapsed)
{
GameObject go = GameObject.Find("RemoteView");
if (remoteView == null)
{
remoteView = go.AddComponent<VideoSurface>();
}
remoteView.SetForUser(uid);
remoteView.SetEnable(true);
remoteView.SetVideoSurfaceType(AgoraVideoSurfaceType.RawImage);
remoteView.SetGameFps(30);
}
void OnUserOffline(uint uid, USER_OFFLINE_REASON reason)
{
remoteView.SetEnable(false);
}
void OnApplicationQuit()
{
if (mRtcEngine != null)
{
IRtcEngine.Destroy();
mRtcEngine = null;
}
}
}
}
But when I press the join button there is only a call of the button(Join method) and the callback OnJoinChannelSuccessHandler is not called.
Source: Windows Questions