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

Bug: Chat Messages Do Not Update in Real-Time (GraphQL Subscriptions Not Utilised) #3230

Open
JaiPannu-IITI opened this issue Feb 17, 2025 · 8 comments
Assignees
Labels
bug Something isn't working no-issue-activity No issue activity

Comments

@JaiPannu-IITI
Copy link

JaiPannu-IITI commented Feb 17, 2025

Current Problem

At present, our chat system requires a full-page reload to fetch new messages. This negatively impacts user experience by:

  • Causing unnecessary delays in message updates.
  • Interrupting user interactions with the page.
  • Increasing server load due to repeated full-page requests.

Image

Proposed Solution

We are already using GraphQL Subscriptions, which leverage WebSockets under the hood for real-time updates. However, our frontend is currently not fully utilising GraphQL Subscriptions to fetch new messages dynamically. Instead, the page requires a full reload to reflect new messages.

To improve real-time messaging, we should ensure the frontend subscribes to GraphQL Subscriptions for instant message updates. This eliminates the need for polling or manual reloads.

Approach

Frontend: PalisadoesFoundation/talawa-admin#3691

  • Ensure GraphQL Subscriptions are properly implemented
  • Confirm that the backend publishes new messages correctly via subscriptions.
  • Validate that WebSockets (graphql-ws or subscriptions-transport-ws) are handling connections efficiently.
  • Modify Frontend to Listen for GraphQL Subscription Events
  • Replace the existing polling/reloading mechanism with useSubscription() in Apollo Client.
  • Update the chat UI dynamically when new messages arrive via GraphQL Subscriptions.
  • Handle Message Persistence & Cache Updates
  • Ensure messages are stored in the database and synced across sessions.
  • Optimise Apollo Client’s cache to avoid redundant queries and improve performance.
  • Error Handling & Reconnection
  • Implement automatic reconnection in case of a dropped WebSocket connection.
  • Ensure the chat remains functional even if the connection temporarily drops.

Benefits of This Improvement:

  • Instant message updates for a better user experience.
  • Reduced server load by eliminating unnecessary HTTP requests.
  • Smoother, modern chat functionality similar to popular messaging apps.

Next Steps:

  • If needed, This feature can later be extended to silent meetings integrating webRTC.
@JaiPannu-IITI JaiPannu-IITI added the bug Something isn't working label Feb 17, 2025
@github-actions github-actions bot added the unapproved Unapproved for Pull Request label Feb 17, 2025
@JaiPannu-IITI
Copy link
Author

JaiPannu-IITI commented Feb 17, 2025

@palisadoes If you think we should be implementing this, I would like to work on this and PalisadoesFoundation/talawa-admin#3691 in pair for convenient devops.

@JaiPannu-IITI JaiPannu-IITI changed the title Issue: Implement WebSocket-Based Real-Time Chat Bug: Implement WebSocket-Based Real-Time Chat Feb 17, 2025
@varshith257
Copy link
Member

Same applies here too use Graphql subscriptions

@palisadoes palisadoes removed the unapproved Unapproved for Pull Request label Feb 17, 2025
@JaiPannu-IITI JaiPannu-IITI changed the title Bug: Implement WebSocket-Based Real-Time Chat Bug: Chat Messages Do Not Update in Real-Time (GraphQL Subscriptions Not Utilised) Feb 17, 2025
@JaiPannu-IITI
Copy link
Author

@varshith257 Graphql subscriptions provide web sockets under the hood, yes we won't add it separately, I wanted issue to be more descriptive but it became unclear, I have modified it. Thankyou for helping.

@palisadoes
Copy link
Contributor

I'll assign this to you. This will make you exceed your 2 issue limit as an exception

@JaiPannu-IITI
Copy link
Author

Thank you so much sir, I’ll ensure that you find the results truly exciting.

@JaiPannu-IITI
Copy link
Author

My exams are about to end, will finalize shortly, please don't consider as inactive.

Copy link

This issue did not get any activity in the past 10 days and will be closed in 180 days if no update occurs. Please check if the develop branch has fixed it and report again or close the issue.

@github-actions github-actions bot added the no-issue-activity No issue activity label Mar 10, 2025
@JaiPannu-IITI
Copy link
Author

Apologies for delay due to exams,Completing by 12EOD.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working no-issue-activity No issue activity
Projects
None yet
Development

No branches or pull requests

3 participants