Skip to content

join failed, errorCode: -10025, due to Perform operation failed due to RTM service is not connected. #210

@pentakotamadhusudhan

Description

@pentakotamadhusudhan

im trying to creat rtm stream channel
and im getting below error :

console output:

Reloaded 1 of 3264 libraries in 4,419ms (compile: 112 ms, reload: 3635 ms, reassemble: 534 ms).
D/EGL_emulation( 7657): app_time_stats: avg=1927.83ms min=9.99ms max=24499.92ms count=13
D/EGL_emulation( 7657): app_time_stats: avg=6211.59ms min=6211.59ms max=6211.59ms count=1
I/spdlog  ( 7657): [2025-03-28 11:38:02.713][12752][I][iris_rtm_api_engine.cc:82] api name RtmClient_createStreamChannel_ae3d0cf params "{"channelName":"madhu_streamchannel_token"}"
I/spdlog  ( 7657): [2025-03-28 11:38:02.766][12752][I][iris_rtm_api_engine.cc:138] api name RtmClient_createStreamChannel_ae3d0cf result {"errorCode":0,"result":0}
I/flutter ( 7657): createStreamChannel success!
I/flutter ( 7657): ------- create channel successfully 
I/spdlog  ( 7657): [2025-03-28 11:38:02.806][12752][I][iris_rtm_api_engine.cc:82] api name StreamChannel_join_2090a6b params "{"channelName":"madhu_streamchannel_token","options":{"token":"007eJxTYDj6/******************************************************************==","withMetadata":true,"withPresence":true,"withLock":true,"beQuiet":false}}"
I/spdlog  ( 7657): [2025-03-28 11:38:02.812][12752][I][iris_rtm_api_engine.cc:138] api name StreamChannel_join_2090a6b result {"requestId":2,"result":0}
I/flutter ( 7657): join failed, errorCode: -10025, due to Perform operation failed due to RTM service is not connected.

import 'package:agora_rtm/agora_rtm.dart';
import 'package:agora_rtc_engine/agora_rtc_engine.dart';
import 'package:flutter/material.dart';
import 'package:tuple/tuple.dart';


class ChatScreen extends StatefulWidget {
  const ChatScreen({super.key});

  @override
  State<ChatScreen> createState() => _ChatScreenState();
}

class _ChatScreenState extends State<ChatScreen> {
  final String channel_name = 'madhu_streamchannel_token';
  late StreamChannel streamChannel;
  late RtmClient rtmClient;
  String appId ="";
  String userId = "madhu_streamchannel_token";

  @override
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    createChannel(channel_name);
    initializeRTM();

  }


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        actions: [
          IconButton(onPressed: (){
            createChannel(channel_name);
          }, icon: Icon(Icons.refresh))
        ],
      ),
      body: Center(child: Text("ufiofoi[f[oief[oijearoufnh"),),
    );
  }


  Future<void> initializeRTM() async {
    try {
      final resultRtm = await RTM(appId, userId);
      rtmClient = resultRtm.$2; // Assign rtmClient at class level
      RtmStatus rtmStatus = resultRtm.$1;

      if (rtmStatus.error) {
        print("RTM Initialization failed: ${rtmStatus.errorCode}, ${rtmStatus.reason}");
      } else {
        print("RTM Client Initialized Successfully");
        await createChannel(channel_name); // Create channel only after successful RTM initialization
      }
    } catch (e) {
      print("RTM Initialization Error: $e");
    }
  }



  Future createChannel(channel_name)async{


    try {
      final resultRtm = await RTM(appId,userId);
      RtmStatus rtmStatus = resultRtm.$1;
      RtmClient rtmClient = resultRtm.$2;
      var result = await rtmClient.createStreamChannel(channel_name);
      RtmStatus status  = result.$1;
      StreamChannel? channel  = result.$2;
      if (status.error == true ){
        print('${status.operation} failed, errorCode: ${status.errorCode}, due to ${status.reason}');
      } else {
        streamChannel = channel! ;
        print('${status.operation} success!');
        print("------- create channel successfully ");
        joinchannel();
      }


    } catch (e) {
      print('something went wrong: $e');
    }


  }
  Future  joinchannel()async{
    var result = await streamChannel.join(
        token: '007e*******************************************3OSMzLS82JL8nPTs1jYAAAcZ4lPg==',
        withMetadata: true, // Subscribe to storage event notifications
        withPresence: true, // Subscribe to the presence event notifications
        withLock: true, // Subscribe to Lock event notifications in this channel
        beQuiet: false); // Whether to subscribe to the channel silently
    // (status, response)
    RtmStatus status = result.$1;
    JoinResult? response = result.$2;
    if (status.error == true ){
      print('${status.operation} failed, errorCode: ${status.errorCode}, due to ${status.reason}');
    } else {
      print('${status.operation} success!');
      print(response);
      print("------- join successfully ");

    }

  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions