首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >支持实时“加入realtime:public:<Channel>时发生错误”

支持实时“加入realtime:public:<Channel>时发生错误”
EN

Stack Overflow用户
提问于 2022-10-23 23:39:28
回答 1查看 193关注 0票数 0

我从Supabase-Js v1升级到了v2。这样做之后,我以前工作的实时订阅都失败了,并创建了以下错误:

问题

这个错误信息意味着什么?为什么会发生错误,我如何修复它?

我认为这个表名是一个频道。

代码语言:javascript
复制
event: "phx_reply"

payload: 
response: {reason: "error occurred when joining realtime:public:<table-name>"}

reason: "error occurred when joining realtime:public:<table-name>"

status: "error" 

ref: "1"
topic: "realtime:public:<table-name>"

我在这里发现了类似的错误信息。不过,我不明白。虽然,我禁用了Postgres行级安全性:

https://github.com/supabase/realtime/issues/217

我的代码

您可以在这里找到完整的代码:

https://github.com/Donnerstagnacht/polity/blob/master/src/app/profile/state/profile.service.ts

代码语言:javascript
复制
CREATE TABLE IF NOT EXISTS public.profiles_counters
(
    "id" uuid NOT NULL,
    "amendment_counter" bigint   DEFAULT 0::bigint,
    "follower_counter" bigint  DEFAULT 0::bigint,
    "following_counter" bigint  DEFAULT 0::bigint,
    "groups_counter" bigint  DEFAULT 0::bigint,
    "unread_notifications_counter" bigint  DEFAULT 0::bigint,
    CONSTRAINT profiles_counters_pkey PRIMARY KEY (id),
    CONSTRAINT profiles_counters_fkey FOREIGN KEY (id)
        REFERENCES auth.users (id) MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
)
TABLESPACE pg_default;
ALTER TABLE IF EXISTS public.profiles_counters OWNER to postgres;
GRANT ALL ON TABLE public.profiles_counters TO anon;
GRANT ALL ON TABLE public.profiles_counters TO authenticated;
GRANT ALL ON TABLE public.profiles_counters TO postgres;
GRANT ALL ON TABLE public.profiles_counters TO service_role;

激活RealTime

代码语言:javascript
复制
begin;
  drop publication if exists supabase_realtime;
  create publication supabase_realtime;
commit;
alter publication supabase_realtime add table profiles_counters;
alter table "profiles_counters" replica identity full;

禁用行级安全

代码语言:javascript
复制
ALTER TABLE profiles_counters DISABLE ROW LEVEL SECURITY;

创建实时订阅

代码语言:javascript
复制
  getRealTimeChangesCounters(uuid: string): RealtimeChannel {
    const subscription = this.supabaseClient
    .channel(`public:profiles_counters`)
    .on('postgres_changes',
      {
        event: 'UPDATE',
        schema: 'public',
        table: 'profiles_counters'
      },
      payload => {
        console.log(payload)
      }
    )
    .subscribe()
    return subscription;

EN

回答 1

Stack Overflow用户

发布于 2022-10-24 15:32:11

它与当前支持的内部bug有关。

我使用了基于Docker的本地开发设置。但是,supabase的停靠映像似乎落后于supabase远程版本(这是supabase文档中描述的版本)。

因此,解决方案是切换到supabase远程开发,并等待本地支持库映像的修复。

相关问题:https://github.com/supabase/realtime/issues/295 https://github.com/supabase/supabase/issues/9798

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74175531

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档