Impossible to join the channel with Agora.io and Unity Standalone (Warning code: 104)

  agora.io, c++, unity3d, windows

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:

  1. Created a new Agora account
  2. Created new appID (tried both with and without the token)
  3. Created a new empty project in unity
  4. Imported from the asset store the SDK
  5. Set the appID and if asked the token (depends if the project was the empty project or the example project on GitHub)
  6. Tried to connect/join the channel
  7. Get errors like:
    Warning code:104 msg:lookup channel timed out (server no response)

Those are the tutorial I followed:

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

LEAVE A COMMENT