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

Realtime doesn't work out of the box or am I missing something? does anyone have it run successfully? #81

Open
virtuman opened this issue Aug 29, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@virtuman
Copy link

virtuman commented Aug 29, 2024

Using latest version of the chart with more or less default values, except for persistent storage and custom KEYs.

everything spins up and looks like it's working, but at least a couple of issues that I can't figure out:

  1. Realtime doesn't seem to work at all, when i try to signup, it says either CHANNEL_ERROR or timeout. I tried using supabase-js and supabase-py, as well as realtime-py packages. Either I can't figure out if I need to change the connection hostname or API Key ?
  2. Notifications do not seem to emit from postgres (that is installed using this helm chart repo)
  3. Google AUTH is excessively difficult to figure out for me nextjs - based app

But realtime is the one that's critical to me and it was the main reason for picking supabase for development.

Stock install of helm chart
Here's the code snippet in nodejs

import { createClient } from '@supabase/supabase-js';

// Supabase credentials
const SUPABASE_URL = 'https://supabase.domain.com'; // this points to kong ingress 
const SUPABASE_KEY = 'zzzzzzzzzzzz_service_key_or_anon_key_value_here'

const supabase = createClient(SUPABASE_URL, SUPABASE_KEY);

const handleError = (error) => {
	console.error('Subscription error:', error);
};

// Function to handle real-time changes
const handleInsert = (payload) => {
	console.log('Insert received:', payload);
};

const channel = supabase.channel('room_a', { broadcast: { ack: false, self: false } })

db.pool.connect((err, client) => {
	if(err) {
		console.log(err);
	}
	pgClient = client;
	client.on('notification', function(msg) {
		console.log('Hello i am new event ')
	});
	const query = client.query('LISTEN myEvent');
});

// Subscribe to real-time updates for the 'pair_meta' table
const setupRealTime = async () => {
	console.log('Setting up real-time subscription...');

	const channel = supabase
		.channel('pair_meta_channel')
		.on('INSERT', handleInsert)
		.on('UPDATE', handleInsert)
		.on('DELETE', handleInsert)
		.subscribe((status, error) => {
			console.log(`Subscription status: ${status}`);
			if (error) {
				handleError(error);
			}
			if (status === 'SUBSCRIBED') {
				console.log('Successfully subscribed to the channel');
			}
		});

	// Handle clean-up on exit
	process.on('SIGINT', async () => {
		console.log('Unsubscribing and exiting...');
		await supabase.removeSubscription(channel);
		process.exit();
	});
};

// Call the setup function
setupRealTime();
@virtuman virtuman added the bug Something isn't working label Aug 29, 2024
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

1 participant