Skip to content

Commit 6530286

Browse files
author
georgiy.rusanov
committed
more logs
1 parent ffef99c commit 6530286

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

.github/workflows/ci.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ jobs:
130130
# Test WebSocket connection with proper authentication parameters
131131
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 direct WebSocket connection to realtime service (bypassing Kong)"
134+
# Test direct connection to realtime service on port 4000
135+
curl -i -N -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Sec-WebSocket-Version: 13" -H "Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==" "http://127.0.0.1:4000/socket/websocket?apikey=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0&vsn=1.0.0" || echo "Direct WS connection failed"
136+
133137
echo "Testing realtime endpoint directly"
134138
curl -v http://127.0.0.1:54321/realtime/v1/ || echo "Realtime endpoint failed"
135139
@@ -142,6 +146,47 @@ jobs:
142146
echo "Testing realtime subscription endpoint"
143147
curl -v -X POST -H "Content-Type: application/json" -H "apikey: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0" -d '{"channel":"test-channel","type":"broadcast"}' http://127.0.0.1:54321/realtime/v1/api/broadcast || echo "Realtime broadcast failed"
144148
149+
echo "Testing direct realtime service endpoints"
150+
curl -v http://127.0.0.1:4000/api/ping || echo "Direct realtime ping failed"
151+
curl -v -H "apikey: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0" http://127.0.0.1:4000/api/ping || echo "Direct realtime ping with auth failed"
152+
153+
echo "Testing WebSocket connection with Node.js"
154+
npm install ws || echo "Failed to install ws package"
155+
node -e "
156+
const WebSocket = require('ws');
157+
const ws = new WebSocket('ws://127.0.0.1:54321/realtime/v1/websocket?apikey=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0&vsn=1.0.0');
158+
159+
ws.on('open', () => {
160+
console.log('WebSocket connection opened');
161+
// Send a phx_join message
162+
const joinMessage = JSON.stringify({
163+
topic: 'realtime:test-channel',
164+
event: 'phx_join',
165+
payload: { config: { broadcast: { self: false }, presence: { key: '' }, private: false } },
166+
ref: '1'
167+
});
168+
console.log('Sending join message:', joinMessage);
169+
ws.send(joinMessage);
170+
});
171+
172+
ws.on('message', (data) => {
173+
console.log('Received message:', data.toString());
174+
});
175+
176+
ws.on('error', (error) => {
177+
console.log('WebSocket error:', error.message);
178+
});
179+
180+
ws.on('close', (code, reason) => {
181+
console.log('WebSocket closed:', code, reason.toString());
182+
});
183+
184+
setTimeout(() => {
185+
console.log('Closing WebSocket connection');
186+
ws.close();
187+
}, 5000);
188+
" || echo "Node.js WebSocket test failed"
189+
145190
docker ps --format '{{.Names}}'
146191
147192
echo "docker logs"

examples/expo-app/app/index.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ export default function Index() {
4949
console.log('Channel state after status:', channel.state)
5050
console.log('Channel topic:', channel.topic)
5151

52+
// Add more detailed debugging for WebSocket state
53+
if (supabase.realtime.conn) {
54+
console.log('WebSocket readyState:', supabase.realtime.conn.readyState)
55+
console.log('WebSocket URL:', supabase.realtime.conn.url)
56+
}
57+
5258
// Show all statuses, not just SUBSCRIBED
5359
setRealtimeStatus(status)
5460
})
@@ -61,11 +67,28 @@ export default function Index() {
6167
console.log('Timeout check - Channel state:', channel.state)
6268
console.log('Timeout check - Channel topic:', channel.topic)
6369

70+
// Check WebSocket connection state
71+
if (supabase.realtime.conn) {
72+
console.log('Timeout check - WebSocket readyState:', supabase.realtime.conn.readyState)
73+
console.log('Timeout check - WebSocket URL:', supabase.realtime.conn.url)
74+
}
75+
76+
// Check if join push was sent
77+
if (channel.joinPush) {
78+
console.log('Timeout check - Join push sent:', channel.joinPush.sent)
79+
console.log('Timeout check - Join push ref:', channel.joinPush.ref)
80+
console.log('Timeout check - Join push receivedResp:', channel.joinPush.receivedResp)
81+
}
82+
6483
// Try to manually check the connection
6584
try {
6685
console.log('Attempting to check realtime connection manually...')
6786
// This might help us understand what's happening
6887
console.log('All channels:', supabase.getChannels())
88+
89+
// Check connection state
90+
console.log('Realtime connection state:', supabase.realtime.connectionState())
91+
console.log('Realtime is connected:', supabase.realtime.isConnected())
6992
} catch (error) {
7093
console.log('Error checking channels:', error)
7194
}

0 commit comments

Comments
 (0)