Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] tokenUrl is not generating the token and giving a 404 Not Found #73

Closed
waqadArshad opened this issue Mar 20, 2022 · 6 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@waqadArshad
Copy link

waqadArshad commented Mar 20, 2022

@maxxfrazer @Ascenio @hxingpax @Meherdeep @tadaspetra
Describe the bug
agora_uikit: ^0.0.4
agora_rtc_engine: ^4.2.0

I hosted https://github.com/AgoraIO-Community/agora-token-service server on Heroku and just copied the base Url of the server: https://nikah----match.herokuapp.com/ as the tokenUrl in the AgoraConnectionData constructor as given here:

final AgoraClient client = AgoraClient(
    agoraConnectionData: AgoraConnectionData(
      appId: "", //omitted for security reasons
      tokenUrl: "https://nikah----match.herokuapp.com",
      // tokenUrl: "https://nikah--match.herokuapp.com/access_token?",
      channelName: channelName,
      uid: 0,
    ),
    enabledPermission: [
      Permission.camera,
      Permission.microphone,
    ],
  );
//the commented line was my previous NodeJS server with old code and different parameters. 
//that's why I hosted this one now as the link in the original AgoraConnectionData class referred //to this server.

and got the error:

I/flutter (15044): Not Found
I/flutter (15044): Failed to generate the token : 404
W/System.err(15044): java.lang.reflect.InvocationTargetException
W/System.err(15044): 	at java.lang.reflect.Method.invoke(Native Method)
W/System.err(15044): 	at io.agora.agora_rtc_engine.AgoraRtcEnginePlugin.onMethodCall(AgoraRtcEnginePlugin.kt:124)
W/System.err(15044): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
W/System.err(15044): 	at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:296)
W/System.err(15044): 	at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$DartMessenger(DartMessenger.java:320)
W/System.err(15044): 	at io.flutter.embedding.engine.dart.-$$Lambda$DartMessenger$TsixYUB5E6FpKhMtCSQVHKE89gQ.run(Unknown Source:12)
W/System.err(15044): 	at android.os.Handler.handleCallback(Handler.java:938)
W/System.err(15044): 	at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err(15044): 	at android.os.Looper.loop(Looper.java:264)
W/System.err(15044): 	at android.app.ActivityThread.main(ActivityThread.java:8282)
W/System.err(15044): 	at java.lang.reflect.Method.invoke(Native Method)
W/System.err(15044): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:632)
W/System.err(15044): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1049)
W/System.err(15044): Caused by: java.lang.NullPointerException: null cannot be cast to non-null type kotlin.String
W/System.err(15044): 	at io.agora.rtc.base.RtcEngineManager.joinChannel(RtcEngine.kt:448)
W/System.err(15044): 	... 13 more
E/flutter (15044): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: MissingPluginException(No implementation found for method joinChannel on channel agora_rtc_engine)
E/flutter (15044): #0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:175:7)
E/flutter (15044): <asynchronous suspension>
E/flutter (15044): #1      SessionController.joinVideoChannel (package:agora_uikit/controllers/session_controller.dart:404:5)
E/flutter (15044): <asynchronous suspension>
E/flutter (15044): #2      AgoraClient.initialize (package:agora_uikit/src/agora_client.dart:69:5)
E/flutter (15044): <asynchronous suspension>
E/flutter (15044): #3      _VideoCallAgoraUIKitState.initAgora (package:nikah_match/view/video_call/agoraUI_video_call.dart:54:5)
E/flutter (15044): <asynchronous suspension>
E/flutter (15044): 


What else I tried:

https://nikah----match.herokuapp.com/rtc

https://nikah----match.herokuapp.com/rtc/test/publisher/uid/0

https://nikah----match.herokuapp.com/rtc/:channelName/publisher/uid/0

https://nikah----match.herokuapp.com/rtc/$channelName/publisher/uid/0

https://nikah----match.herokuapp.com/rtc/:channelName/:role/:tokentype/:uid

To Reproduce
Steps to reproduce the behavior:

  1. use the given code with the agora_uikit: ^0.0.4
  2. See the console

Expected behavior
A token is generated and the call starts.

Screenshots
If applicable, add screenshots to help explain your problem (N/A).

Desktop (please complete the following information):

  • OS: Windows

Smartphone (please complete the following information):

  • Device: OPPO F15
  • OS: Android 11

Additional context
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.10.3, on Microsoft Windows [Version 10.0.19044.1526], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Build Tools 2019 16.11.10)
[√] Android Studio (version 2021.1)
[√] IntelliJ IDEA Community Edition (version 2021.3)
[√] VS Code (version 1.65.2)
[√] Connected device (4 available)
[√] HTTP Host Availability

• No issues found!

@waqadArshad waqadArshad added the bug Something isn't working label Mar 20, 2022
@maxxfrazer
Copy link
Contributor

addressed in AgoraIO-Community/agora-token-service#22

@waqadArshad to save yourself time, it might be easier to use Postman, or a similar tool for checking that your token server is running properly.

@waqadArshad
Copy link
Author

The token is being generated when I am using the link in a browser. The thing is that there is no documentation stating, how that link is being used by the Agora UI Kit. I mean which parameters are being placed where inside the link, is not documented at all.

@waqadArshad
Copy link
Author

@maxxfrazer and I think you should at least wait for the Author's answer before closing an issue.

@maxxfrazer
Copy link
Contributor

The correct URL for you and your colleague is:
"https://nikah----match.herokuapp.com"

This project is all open source, corresponding code is here:
https://github.com/AgoraIO-Community/Flutter-UIKit/blob/829db279ad14a4af6828cb522ca96b8c2a3dd9d4/lib/controllers/session_controller.dart#L631

I'd suggest modifying the local copy of that to print out the full URL that it uses, just to check. If it comes back with anything other than "https://nikah----match.herokuapp.com/rtc/test/publisher/uid/0", then we will have an issue.

This is a small dart script that uses the same code and prints the token correctly:

import 'package:http/http.dart' as http;
import 'dart:convert';

void main(List<String> arguments) {
  getToken(
    tokenUrl: "https://nikah----match.herokuapp.com",
    channelName: "test",
    uid: 0,
  );
}

Future<void> getToken({
  String? tokenUrl,
  String? channelName,
  int uid = 0,
}) async {
  final response = await http
      .get(Uri.parse('$tokenUrl/rtc/$channelName/publisher/uid/$uid'));
  if (response.statusCode == 200) {
    print(jsonDecode(response.body)['rtcToken']);
  } else {
    print(response.reasonPhrase);
    print('Failed to generate the token : ${response.statusCode}');
  }
}

@maxxfrazer maxxfrazer reopened this Mar 21, 2022
@maxxfrazer
Copy link
Contributor

No answer from author… closing issue again

@waqadArshad
Copy link
Author

Yes sorry for the delayed response. I was really busy these past few days. Yes, it seems to be working just fine now.

@maxxfrazer Thanks a lot for the help. I really appreciate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants