Hello, even though I did many research, I did not ...
# help
r
Hello, even though I did many research, I did not find a solution
When I run this code:
Copy code
ts
  supabase
    .from("Posts")
    .on("INSERT", (payload) => {
      posts.value.push(payload.new);
    })
    .subscribe();
I get this error:
WebSocket connection to wss:url failed
I followed the docs and checked some tutorials, they use the same code, weirdly not working on mine. I also tried @supabase/realtime-js which gave the same error I enabled replication setting, too
g
Strangely I just had a couple of wss error messages in my hosted test site console log over the past few hours, but now seems it is working fine. That is referring to the realtime url not connecting. In your supabase client init, there is a realtime url in the response. At one time it was wws for supabase server and ws for localhost, not sure if that is still the case.
r
Copy code
ts
const supabase = createClient(SUPABASE_URL, SUPABASE_KEY);
@User this is my client, may there be any problem?
g
look in supabase object and see what realtime url is.
r
how can I do it
oh saw it
wss://myurl.supabase.co/realtime/v1
like this
it is like my url but starts with wss and ends with realtime v1
g
That is correct for using hosted supabase then. Are you still getting the error? I'm not, but unfortunately I lost my trace with the error in it from earlier today. Seems like a supabase glitch.
r
nah I am still having error
Copy code
ts
const supabase = createClient(SUPABASE_URL, SUPABASE_KEY);
console.log(supabase);

export const usePosts = () => {
  const posts = ref<any[]>([]);

  supabase
    .from("Posts")
    .select("*")
    .then((value) => {
      if (value.data) posts.value = value.data;
    });

  // supabase
  //   .from("Posts")
  //   .on("INSERT", (payload) => {
  //     posts.value.push(payload.new);
  //   })
  //   .subscribe();

  return posts;
};
when I uncomment that part, I get the error
btw I get the Posts without any problem above
g
The error I'm pretty sure means your realtime can't connect for some reason to the server. I've never seen that error until earlier today.
Copy code
const mySubscription = supabase
        .from('test5')
        .on('*', payload => {
            console.log('Change received!', payload)
        })
        .subscribe((status, e) => {
            console.log('status', status, e)
        })
Your call looks correct.
r
connection is also correct, because I can read the data
when I change any letter, I get error for getting, but now working
@User Tried it again today
it did not work 😦 sadly
maybe @User can help about it?
Btw, it shows the requests here
w
@User can you please email support@supabase.io with your project ref? We can then investigate your project’s realtime
r
it is actually only this code
.
but will do
might there be any authentiation problem? such as user must be logged etc?
I mean it is logged and there is a access token in local storage but I did not do anything else
Sadly the help support gave did not work 😦
w
@User i have to investigate further. there's an issue with authenticating the socket connection.
we have found the issue and will be deploying a fix very soon
r
Ohh nice to hear
You are very helpful
Thank you @User
Hey, sorry to message again but it is still not working
Is there any expected time for it to be fixed?
w
Oh weird we deployed the fix to your project first yesterday
Sorry about that. Let me check again.
r
Definitely no problem, I am just excited to use it
w
@User I checked after deploying that new projects were working once again. The fastest way to get unblocked is to create another new project. Apologies, I know that’s what I said last time.
r
ahh, let me try it again
w
Appreciate it!
r
Thank you for your response again
It now works without any problem 🙂
I actually appreciate how Supabase replied my mails imediately, have a good day!
w
Awesome, enjoy!