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

Subscription auto closed #225

Closed
asxoxdev opened this issue Sep 26, 2022 · 1 comment · Fixed by #226
Closed

Subscription auto closed #225

asxoxdev opened this issue Sep 26, 2022 · 1 comment · Fixed by #226
Labels
bug Something isn't working realtime This issue or pull request is related to realtime

Comments

@asxoxdev
Copy link

asxoxdev commented Sep 26, 2022

Subscription auto closed after around 30 seconds without manually closing.
I received all event before around 30 seconds perfectly but after that time subscription closed automatically.
it's go the same for stream too.
Please help me.I am struggling for along time.
I tried this on both versions ^1.0.0-dev.8 and 0.3.3

I don't want to close my subscription until I manually close it by calling supabase.removeSubscription(mySubscription);

here is code example

import 'package:flutter/material.dart';
import 'package:supabase_flutter/supabase_flutter.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  String superbaseUrl = "url";
  String anonKey =  "anon key";
  await Supabase.initialize(anonKey: anonKey, url: superbaseUrl);
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Test Supabase',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const Test(),
    );
  }
}

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

  @override
  State<Test> createState() => _TestState();
}

class _TestState extends State<Test> {
  final client = Supabase.instance.client;
  late final RealtimeSubscription subscription;

  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addPostFrameCallback(
      (_) {
        subscription = client.from("message").on(
          SupabaseEventTypes.all,
          (payload) {
            log("payload $payload");
          },
        ).subscribe(
          (event, {errorMsg}) {
            log("event $event");
          },
        );
      },
    );
  }

  @override
  void dispose() {
    client.removeSubscription(subscription);
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return const Scaffold();
  }
}
@asxoxdev asxoxdev added the bug Something isn't working label Sep 26, 2022
@Vinzent03 Vinzent03 added the realtime This issue or pull request is related to realtime label Sep 26, 2022
@dshukertjr
Copy link
Member

Thanks @asxoxdev for opening this issue. It seems like there are some other folks experiencing the same issue as well.
supabase/supabase#9146 (reply in thread)

We are looking into this and will post an update if we make any progress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working realtime This issue or pull request is related to realtime
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants