DEV Community

Cover image for Build a Scalable Video Chat App with Agora in Django

Build a Scalable Video Chat App with Agora in Django

Kofi Mupati on April 13, 2021

Introduction Django is a high-level Python Web framework that takes care of much of the hassle of Web development so that you can focus ...
Collapse
 
sohanurshanto profile image
sohanur-shanto

Hi, Kofi mupati. I followed your all instructions and got an error. Can you please check that. Please give me a solution man.

File "C:\Users\Ehsan Software\AppData\Local\Programs\Python\Python38\lib\site-packages\pusher\client.py", line 37, in init
self._app_id = ensure_text(app_id, "app_id")
File "C:\Users\Ehsan Software\AppData\Local\Programs\Python\Python38\lib\site-packages\pusher\util.py", line 42, in ensure_text
raise TypeError("%s should be %s instead it is a %s" % (name, text, type(obj)))
TypeError: app_id should be a string instead it is a

Collapse
 
mupati profile image
Kofi Mupati

did you add the pusher credentials to the .env file?

Collapse
 
sohanurshanto profile image
sohanur-shanto

@mupati sorry about the late reply, I had weekend. Thanks for getting in touch. Yes I had added the pusher credentials to the .env files.

Thread Thread
 
sohanurshanto profile image
sohanur-shanto

PUSHER_APP_ID= '1213947'
PUSHER_APP_KEY='2782f26c53ee13fb1ca2'
PUSHER_APP_SECRET= '8430a8454b6461e5e68e'
PUSHER_APP_CLUSTER= 'ap3'

AGORA_APP_ID= 'c00816fe3db3414584e35532dc2c43ae'
AGORA_APP_CERTIFICATE= '1c7ba4845b4945f0b9c6fe2a74835d70'

I cloned your github repo. rename the file .env.example to .env and save those credentials.
give me a solution man.

Thread Thread
 
mupati profile image
Kofi Mupati

found the error. I made a mistake in the env variable names. I should be the following instead

PUSHER_APP_ID=
PUSHER_KEY=
PUSHER_SECRET=
PUSHER_CLUSTER=
AGORA_APP_ID=
AGORA_APP_CERTIFICATE=

I've updated the post with the right ones.

Thread Thread
 
sohanurshanto profile image
sohanur-shanto

which post? can you share the link? This will be great

Thread Thread
 
sudarshanbb profile image
Sudarshan

You got any solution for the same or any link ,please share me

Thread Thread
 
mupati profile image
Kofi Mupati

@sohanurshanto I made errors in the environment variable names. I've shared the correct one in this thread. I've also updated this same article to correct the mistake.

Thread Thread
 
sudarshanbb profile image
Sudarshan

thanks

Thread Thread
 
sudarshanbb profile image
Sudarshan

Hello brother ,I am still stuck on one problem. When I am login through admin panel site window will be there but status of offline to online not converting ,please help me out friend .I am sending you screenshot also

Thread Thread
 
mupati profile image
Kofi Mupati • Edited

There's a mistake. In the index.html file, Replace 420e941c25574fda6378 with your own Pusher ID. The one over there is mine. I've updated the article to include this. The online status should work after that.

      window.pusher = new Pusher("420e941c25574fda6378", {
        authEndpoint: "{% url 'agora-pusher-auth' %}",
        auth: {
          headers: {
            "X-CSRFToken": "{{ csrf_token }}",
          },
        },
      });
Enter fullscreen mode Exit fullscreen mode
Thread Thread
 
sudarshanbb profile image
Sudarshan

Hello , I changed the pusher key to mine but still it not changes its status from offline to online. Can you please check ones again what is the mistake and if possible please send us demo video with full tutorial its lot for us, thank you

Thread Thread
 
mupati profile image
Kofi Mupati

check whether the environment variable names in your env file match with what you have in the views. I made some mistakes with that which I've corrected.

You can go through the article once more.

Collapse
 
sajzad profile image
Mohammad Rabeul Hasan

Thanks bro for your nice project. One thing may i ask on adding on feature if call is cancelled by one end, the other end will also be cancelled without pressing the stop button. Is something possible?

Collapse
 
mupati profile image
Kofi Mupati

yeah it's possible. all you need is send the appropriate event through websockets from one user to the other. You listen for the event at one end and perform the action you want.

Collapse
 
naeem23 profile image
Nae'3m

I have downloaded your repository and set up the virtual environment. After that I changed .env file with my credentials and also changed the index.html page pusher key. Unfortunately I am still getting offline. here is my pusher's data:
app_id = "1251606"
key = "4ad850a59d4a4ddaff01"
secret = "a9c40019b5f9c3003e99"
cluster = "ap2"
I have read your comments but couldn't find a solution. Please help me to figure it out.

Collapse
 
mupati profile image
Kofi Mupati

pass the pusher cluster into the Pusher instance and let me know if it works.

      window.pusher = new Pusher("420e941c25574fda6378", {
        cluster: "APP_CLUSTER",
        authEndpoint: "{% url 'agora-pusher-auth' %}",
        auth: {
          headers: {
            "X-CSRFToken": "{{ csrf_token }}",
          },
        },
      });
Enter fullscreen mode Exit fullscreen mode
Collapse
 
ajays05 profile image
Ajay Somaiya

Hello, I am having the issue of seeing the other users always as offline but I checked the spellings of environment variables and their values, changed the pusher key and inserted it again .
this is my .env file
PUSHER_APP_ID = 1243969
PUSHER_KEY = fd4655d98dd01fb8e82c
PUSHER_SECRET = aaf7b522efb285c73f06
PUSHER_CLUSTER = ap2
AGORA_APP_ID = 1edd45d115d04c2f83a3db514a8953b1
AGORA_APP_CERTIFICATE = 91dac37a4d28434f837c63bfd24e161a

and I swapped between inverted colons, double inverted colons and no inverted colon for values

Collapse
 
abnaparveen profile image
abnaparveen

I logged in incognito tab and normal tab. but its seems offline. I am not able to connect call. I attached the screenshot here. I used local server not https or live server. I don't know how to use it. can you help me for the same

Collapse
 
abnaparveen profile image
abnaparveen
Collapse
 
mupati profile image
Kofi Mupati

Please can you confirm whether your pusher connection is working well?

Collapse
 
jhkeilson profile image
Jon Keilson

Hi, this worked great for me but I did notice when Agora SDK kicks in for streaming I get a warning in Chrome. Is the support for this SDK going to be an issue come July?

...
[Deprecation] Plan B SDP semantics, which is used when constructing an RTCPeerConnection with {sdpSemantics:"plan-b"}, is a legacy version of the Session Description Protocol that has severe compatibility issues on modern browsers. The standardized SDP format, "unified-plan", has been used by default since M72 (January, 2019). Dropping support for Plan B is targeted for M93 (Canary: July 15, 2021; Stable: August 24, 2021).

Collapse
 
mupati profile image
Kofi Mupati

I'm glad you found it helpful. I can't tell for now but if possible use the latest stable SDK available.

Collapse
 
coderrohanpahwa profile image
coderrohanpahwa

I am always getting status as offline being I logged in with incognito tab as well as my normal tab as well.Can you help me for the same?

Collapse
 
mupati profile image
Kofi Mupati

Can you confirm whether Pusher has been properly configured. Do that, refresh browser and try again.

Collapse
 
coderrohanpahwa profile image
coderrohanpahwa

You have hard coded a string (I am attaching a screenshot you can see in that ) Do I have to change that or will it be like that only? Also can you tell me how can I cross check if pusher is configured properly or not?

Thread Thread
 
mupati profile image
Kofi Mupati

where is the screenshot

Thread Thread
 
coderrohanpahwa profile image
coderrohanpahwa
Thread Thread
 
mupati profile image
Kofi Mupati • Edited

Yeah. thanks for pointing it out. That is the pusher key. Replace that with yours. I'll update the post to reflect that. I'm not sure there are any security concerns with having your pusher key visible. the pusher secret must be kept secret, pun intended.

Collapse
 
andrian profile image
Andrian

I have followed your directions but there is still a problem in the status is still offline ...
pls hellp me ..

Collapse
 
mupati profile image
Kofi Mupati

can you confirm if your pusher keys are correct?

Collapse
 
andrian profile image
Andrian

PUSHER_KEY='65c0628332bed3678a4f'

<br> window.pusher = new Pusher(&quot;65c0628332bed3678a4f&quot;, {</p> <p>like this ?</p>

Thread Thread
 
mupati profile image
Kofi Mupati

yeah. what about the backend?

Thread Thread
 
andrian profile image
Andrian
Collapse
 
bashar profile image
Bashar Al-Abdulhadi

fleet-server.herokuapp.com/agora/l... hyperlink is pointing to github.com/Mupati/agora-django-vid... maybe you want to update it :)

Collapse
 
andrian profile image
Andrian

@bashar Al-Abdulhadi may i have your code?

Collapse
 
bashar profile image
Bashar Al-Abdulhadi

didn't get you, which code?

Collapse
 
mupati profile image
Kofi Mupati

Thanks for pointing it out.

Collapse
 
aliplutus profile image
aliplutus

is this applicable for DRF

Collapse
 
mupati profile image
Kofi Mupati

You can tweak it and implement the same with DRF

Collapse
 
sudarshanbb profile image
Sudarshan

I got the same error ,Kofi mupati help me for the same

Hi, Kofi mupati. I followed your all instructions and got an error. Can you please check that. Please give me a solution man.

File "C:\Users\Ehsan Software\AppData\Local\Programs\Python\Python38\lib\site-packages\pusher\client.py", line 37, in init
self._app_id = ensure_text(app_id, "app_id")
File "C:\Users\Ehsan Software\AppData\Local\Programs\Python\Python38\lib\site-packages\pusher\util.py", line 42, in ensure_text
raise TypeError("%s should be %s instead it is a %s" % (name, text, type(obj)))
TypeError: app_id should be a string instead it is a

Thread Thread
 
anushka207 profile image
anushka207

were you able to find a solution for this problem, if yes then please share the solution with me also, because i am also facing the smae problem

Thread Thread
 
sudarshanbb profile image
Sudarshan

No, I am still working on the same issue. I don't know how to change offline status to online ,if you got any solution plz help me out.

Collapse
 
andrian profile image
Andrian

Offline ?

Collapse
 
thw98 profile image
thw98

Hi, what if I want to show some alert to the caller when the call had been declined?

Collapse
 
mupati profile image
Kofi Mupati

That's also possible. You just need to sent an "call-declined" event to the caller after they decline.

Collapse
 
sanjayraou profile image
sanjayraou

Sir, After I have completed the whole project the server runs successfully but It shows an error 404 Page not found

Collapse
 
pratistha profile image
Shrestha Pratistha • Edited

Hello, When I am login through admin panel site or custom dashboard window will be there but status of offline to online not converting
Can u help me with it?