Hi i'm trying to setup agora.io in a react/next typescript project, but i have this error in my console:
Agora-SDK [ERROR]: [client-a361f] join number: 1, Joining channel failed, rollback AgoraRTCException: AgoraRTCError CAN_NOT_GET_GATEWAY_SERVER: flag: 4096, message: AgoraRTCError CAN_NOT_GET_GATEWAY_SERVER: invalid vendor key, can not find appid
and
Failed to join the channel AgoraRTCException: AgoraRTCError CAN_NOT_GET_GATEWAY_SERVER: flag: 4096, message: AgoraRTCError CAN_NOT_GET_GATEWAY_SERVER: invalid vendor key, can not find appid
This is my App.js
import AgoraRTC, { AgoraRTCProvider } from "agora-rtc-react";
const config = { mode: "rtc", codec: "vp8" };
const agoraClient = AgoraRTC.createClient(config);
function App() {
return (
<AgoraRTCProvider client={agoraClient}>
// Here my comonents
</AgoraRTCProvider>
);
}
export default App;
and here my component where i try Agora
"use client";
import { useState, useEffect, useRef } from "react";
import {
useRTCClient,
useLocalCameraTrack,
useLocalMicrophoneTrack,
usePublish,
useIsConnected,
LocalVideoTrack,
} from "agora-rtc-react";
const AppID = process.env.REACT_APP_AGORA_ID; // from agora console
const Token = process.env.REACT_APP_AGORA_TOKEN; // from agora console try primary and secondary certificate
const VideoComponent = () => {
const client = useRTCClient();
const { localCameraTrack } = useLocalCameraTrack();
const { localMicrophoneTrack } = useLocalMicrophoneTrack();
const [isPublished, setIsPublished] = useState(false);
const videoRef = useRef < HTMLDivElement > null;
const ChannelName = `AGORA_CHANNEL_ID_1`;
useEffect(() => {
const init = async () => {
try {
await client.join(AppID, ChannelName, Token, 120);
if (localCameraTrack && localMicrophoneTrack) {
await client.publish([
localCameraTrack,
localMicrophoneTrack,
]);
setIsPublished(true);
}
} catch (error) {
console.error("Failed to join the channel", error);
}
};
init();
return () => {
localCameraTrack && localCameraTrack.close();
localMicrophoneTrack && localMicrophoneTrack.close();
client.leave();
};
}, [
client,
localCameraTrack,
localMicrophoneTrack,
AppID,
ChannelName,
Token,
]);
useEffect(() => {
if (localCameraTrack && videoRef.current) {
localCameraTrack.play(videoRef.current);
}
}, [localCameraTrack]);
return (
<div>
{localCameraTrack && <div ref={videoRef} className="local-video" />}
</div>
);
};
export default AgoraComponent;
I don't know why i have this error,
