fix: Fix for Realtime Functionality in Supabase-on-AWS Description #86
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While implementing supabase-on-aws, I encountered an issue where the realtime functionality was not working as expected. After investigating, I found a similar issue reported on the Supabase Realtime GitHub repository supabase/realtime#372, which led me to a solution.
Changes Made
Updated Realtime Version in Supabase Stack
I updated the Docker image version for the Supabase Realtime service in src/supabase-stack.ts to resolve the initial issue with the Realtime service not functioning properly.
This change allowed the following code to work, enabling successful subscription and message broadcast between clients:
Identified Issue with API-based Messaging
However, I noticed that sending messages via the API instead of directly through WebSockets did not work. This issue was discussed in a Supabase community discussion https://github.com/orgs/supabase/discussions/18790#discussioncomment-7580134.
Configuration Adjustments in Kong Template
To address this, I made adjustments in the containers/kong/kong-template.yml to properly route Realtime and Realtime-API requests, and updated environment variables in src/supabase-stack.ts for consistency.
Updated SUPABASE_REALTIME_URL to SUPABASE_REALTIME_SOCKET_URL and added SUPABASE_REALTIME_API_URL.
Updated the Kong Docker image to a newer version with a revised kong-template.yml.
// containers/kong/kong-template.yml
// src/supabase-stack.ts
Final Outcome
After making these changes, both WebSocket-based and API-based messaging functionalities were working as expected, resolving the initial issue with the Realtime service.
// Example of client code with successful Realtime functionality
Conclusion
I hope this pull request will be merged to help others facing similar issues with Realtime functionality in Supabase-on-AWS. This solution has been tested and confirmed to work, providing a path forward for those experiencing similar challenges.