I'm writing a chat application from scratch, and I'm trying to figure out the best way to retrieve messages from the server in real time. I've done a fair amount of research, and have come up with this: I could use web sockets, and I've seen it done before successfully. I could use long polling, but I'm wondering if that places greater stress on the server, or maybe is just not right for a chat application. I could poll the server every second, but that just seems like a waste of bandwidth. Suggestions? Thank you!
What's the best way to retrieve messages from the server for a chat application
248 views Asked by Christopher Shroba At
2
There are 2 answers
0
Chris Terrell
On
What? Do you need to and from a database on a dedicated server? I would recommend Ajax with JavaScript or jQuery but i like to do my own coding so JavaScript. If your showing data back and forth match i would probably use MySQL.
For example to query up the last known query if matches current then would not be updated. If doesn't match loop up from last to rent match would be DESC if in Order by type. Anyways... Hope this helps you decide on what you should use.
Although this is what is common on games, blogs, forums, chats with MySQL/SQL.
Related Questions in JAVASCRIPT
- Using Puppeteer to scrape a public API only when the data changes
- inline SVG text (js)
- An array of images and a for loop display the buttons. How to assign each button to open its own block by name?
- Storing the preferred font-size in localStorage
- Simple movie API request not showing up in the console log
- Authenticate Flask rest API
- Deploying sveltekit app with gunjs on vercel throws cannot find module './lib/text-encoding'
- How to request administrator rights?
- mp4 embedded videos within github pages website not loading
- Scrimba tutorial was working, suddenly stopped even trying the default
- In Datatables, start value resets to 0, when column sorting
- How do I link two models in mongoose?
- parameter values only being sent to certain columns in google sheet?
- Run main several times of wasm in browser
- Variable inside a Variable, not updating
Related Questions in WEBSOCKET
- Resolving ElephantIO ServerConnectionFailureException: Error establishing connection to server
- Django socketio process
- How to decode audio stream using tornado websocket?
- Java and React WebSocket - Error Connection
- Socket.io nodejs server .NET connection
- Troubleshooting WebSocket 502 Error in Python Code
- Getting an error in Socket.io wordle project
- Best practices with realtime data / websockets. Send vs. revalidate data
- My socket.io web socket application is not sending data to some users
- Android 13 & 14 seem to close WebSocket connection, if i put app in background, after ~20s
- Audio bytes chunks getting corrupted during streaming using Django and Websockets
- Odoo live chat not working when using apache reverse proxy
- websocket Fatal error message stating "Failed to listen on tcp://0.0.0.0:8080: Address already in use
- Stomp connection using JWT token in Python
- Symphony Fintech (XTS) market-data socket data integration in PyQt6 using python3
Related Questions in SOCKET.IO
- How to Socket.IO Multithreading on a Raspberry Pi?
- Error while uploading the socket io chat app
- Socket.io nodejs server .NET connection
- Getting an error in Socket.io wordle project
- User is connecting to socket.io server twice
- Using Bun+Elysia+socket.io together
- Socket.io event doesn't emitting from client itself client
- Socket.io not emitting event to node server on react native
- My socket.io web socket application is not sending data to some users
- Web RTC simple peer connection with socket.io could not be established
- socket io working fine on local environment but causes problem when run using deployed site
- rasa not responding when setting the value of session_persistence: true using socket
- open-telemetry observable gauge in js - how to access field used in observable gauge inside socket.io method
- Socket io not working during deployment on vercel
- Socket.io Deployment
Related Questions in LONG-POLLING
- Java, Telegram Bot runtime problems
- How do I detect client disconnect from a long poll to a Spring endpoint
- How to update all clients when a webhook is recieved in Python Flask
- HTTP Longpolling with changing request parameters using rxjs
- Laravel rest api - calling SSE or Long polling blocks other HTTP request
- PHP script doesn't quit when browser connection is closed
- During tomcat/jersey shutdown while long polling, the ServletContextListener hook is delayed by 7 seconds, why?
- How to occasionally push notifications to mobile applications?
- Socket.io with http polling without sticky sessions in a distributed system
- Implementing long polling with python multiprocessing but doesn't work
- How can I save a photo from a telegram bot user to a folder on a disk in good quality?
- Long Polling with an array php Javascript
- Long-polling with message queues in a clustered environment
- Bi-Directional Vs Uni-Directional communication
- Tomcat, NGINX, Vaadin, Spring Boot and LONG POLLING Push
Related Questions in SERVER-PUSH
- Is it okay to call rest API in every 5 seconds to receive update Android/iOS UX?
- Vaadin 14 - Closing IFrame after request from an other application
- How to use Vaadin FLOW server-push with Spring Boot
- CUBA Platform push messages from backend to UI
- HTTP Server-Push: Service to Service, without Browser
- What happens when triggering a GET request while a http2 push is in-flight for the same resource
- How web push protocol works?
- HTTP/2 Server Push not working for JavaScript files
- Can a HTTP/2 client choose which resources to receive via Server Push?
- is HTTP2 viable for video streaming or real-time multiplayer games?
- How to fetch values from dict
- With HTTP/2 Push, can I push assets before the initial response?
- HTTP/2 Server Push results in duplicate requests
- How to limit amount of files sent to HTTP 2 / Server Push + Nginx
- How can I check that HTTP2/Server Push works properly?
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
The websocket protocol is ideal for something like a chat application for several reasons.
So to answer your question. You should definitely go with web sockets. Since you lack traditional headers, you will have to do a bit of work when it comes to formatting the messages sent over the connection, but the efficiency is well worth the minimal effort it takes to set up your messaging model.