Skip to content

Commit 9dd17a5

Browse files
author
georgiy.rusanov
committed
looking the problem with realtime
1 parent e4f2f8c commit 9dd17a5

File tree

3 files changed

+40
-8
lines changed

3 files changed

+40
-8
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,19 +123,22 @@ jobs:
123123
124124
- name: Debug Supabase connectivity
125125
run: |
126-
echo "Checking HTTP endpoint with curl..."
126+
echo "Checking HTTP endpoint with curl"
127127
curl -v http://127.0.0.1:54321 || echo "curl failed"
128128
129-
echo "Testing WebSocket connection to supabase realtime..."
130-
# Test WebSocket connection using curl (which supports WebSocket)
131-
curl -i -N -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Sec-WebSocket-Version: 13" -H "Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==" http://127.0.0.1:54321/realtime/v1/websocket || echo "WS connection failed"
129+
echo "Testing WebSocket connection to supabase realtime with auth"
130+
# Test WebSocket connection with proper authentication parameters
131+
curl -i -N -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Sec-WebSocket-Version: 13" -H "Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==" "http://127.0.0.1:54321/realtime/v1/websocket?apikey=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0&vsn=1.0.0" || echo "WS connection failed"
132132
133-
echo "Testing realtime endpoint directly..."
133+
echo "Testing realtime endpoint directly"
134134
curl -v http://127.0.0.1:54321/realtime/v1/ || echo "Realtime endpoint failed"
135135
136-
echo "Testing realtime health check..."
136+
echo "Testing realtime health check"
137137
curl -v http://127.0.0.1:54321/realtime/v1/api/ping || echo "Realtime ping failed"
138138
139+
echo "Testing realtime health check with auth"
140+
curl -v -H "apikey: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0" http://127.0.0.1:54321/realtime/v1/api/ping || echo "Realtime ping with auth failed"
141+
139142
docker ps --format '{{.Names}}'
140143
141144
echo "docker logs"
@@ -147,7 +150,13 @@ jobs:
147150
echo "Checking realtime container specifically..."
148151
docker logs supabase_realtime_supabase-js --tail 50 || echo "No realtime logs"
149152
153+
echo "Checking Kong logs for WebSocket requests..."
154+
docker logs supabase_kong_supabase-js --tail 20 || echo "No Kong logs"
155+
150156
- name: Build and test expo
157+
env:
158+
SUPABASE_URL: http://127.0.0.1:54321
159+
SUPABASE_ANON_KEY: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0
151160
run: |
152161
npm clean-install
153162
npm run build

examples/expo-app/__tests__/Index.test.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ describe('Index', () => {
88

99
it('should display SUBSCRIBED status when realtime connection is established', async () => {
1010
console.log('Starting realtime connection test...')
11+
console.log('Environment variables:')
12+
console.log('- SUPABASE_URL:', process.env.SUPABASE_URL || 'not set')
13+
console.log('- SUPABASE_ANON_KEY:', process.env.SUPABASE_ANON_KEY ? 'set' : 'not set')
14+
1115
const { getByTestId, unmount } = render(<Index />)
1216

1317
// Initially, the text should be empty
@@ -26,6 +30,12 @@ describe('Index', () => {
2630
onTimeout: (error) => {
2731
const currentStatus = getByTestId('realtime_status').props.children
2832
console.error('Test timeout. Current status:', currentStatus)
33+
console.error('Environment check:')
34+
console.error('- SUPABASE_URL:', process.env.SUPABASE_URL)
35+
console.error(
36+
'- SUPABASE_ANON_KEY:',
37+
process.env.SUPABASE_ANON_KEY ? 'present' : 'missing'
38+
)
2939
throw new Error(
3040
`Timeout waiting for SUBSCRIBED status. Current status: ${currentStatus}. ${error.message}`
3141
)

examples/expo-app/app/index.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,30 @@ import { Text, View } from 'react-native'
22
import { useState, useEffect } from 'react'
33
import { createClient } from '@supabase/supabase-js'
44

5-
const SUPABASE_URL = 'http://127.0.0.1:54321'
5+
// Use environment variables with fallbacks for local development
6+
const SUPABASE_URL = process.env.SUPABASE_URL || 'http://127.0.0.1:54321'
67
const ANON_KEY =
8+
process.env.SUPABASE_ANON_KEY ||
79
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0'
810

9-
const supabase = createClient(SUPABASE_URL, ANON_KEY)
11+
console.log('Using Supabase URL:', SUPABASE_URL)
12+
console.log('Using Supabase Key:', ANON_KEY.substring(0, 20) + '...')
13+
14+
const supabase = createClient(SUPABASE_URL, ANON_KEY, {
15+
realtime: {
16+
params: {
17+
eventsPerSecond: 10,
18+
},
19+
},
20+
})
1021

1122
export default function Index() {
1223
const [realtimeStatus, setRealtimeStatus] = useState<string | null>(null)
1324

1425
useEffect(() => {
1526
console.log('Setting up realtime connection...')
27+
console.log('Realtime URL:', supabase.realtime.endPoint)
28+
1629
const channel = supabase.channel('realtime:public:todos')
1730

1831
channel.subscribe((status) => {

0 commit comments

Comments
 (0)