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
247 Views Asked by Christopher Shroba At
2
There are 2 best solutions below
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
- Angular Show All When No Filter Is Supplied
- Why does a function show up as not defined
- I count the time the user takes to solve my quiz using Javascript but I want the same time displayed on another page
- Set "More" "Less" font size
- Using pagination on a table in AngularJS
- How to sort these using Javascript or Jquery Most effectively
- how to fill out the table with next values in array with one button
- State with different subviews
- Ajax jQuery firing multiple time display event for the same result
- Getting and passing MVC Model data to AngularJS controller
- Disable variable in eval
- javascript nested loops waiting for user input
- .hover() seems to overwrite .click()
- How to sort a multi-dimensional array by the second array in descending order?
- How do I find the fonts that are not loading in a CORS situation ( MoovWeb )?
Related Questions in WEBSOCKET
- How to send raw data using socket.io
- HttpRequestContext vs HttpContext
- Websocket support on JBoss 6
- How to send/receive messages through a web socket on windows phone 8.1
- Stop receiving an event for some time in socket io
- Nginx not passing websocket upgrade response back to client?
- Jboss showing this error in eclipse
- Oauth in Tyrus WebSocket
- Meteor: Workaround for having websockets blocked in port 80?
- Python Server - Processing WebSocket.close()
- Multithread using Executor and WebSocket
- Start Rumpetroll on Debian
- What are the possible bugs that cause slow response (sometimes but not all the time) for a websocket connection?
- Ratchet websocket server not responding after some hour
- Angularjs data is not updated on call of $apply
Related Questions in SOCKET.IO
- How to send raw data using socket.io
- Stop receiving an event for some time in socket io
- Socket.io chat application not working with express?
- Deleting namespace in Socket IO
- Connecting a web client to a c++ server with TCP
- Node.js - Socket.io io.emit() doing nothing
- Angular.js - How to make limitTo dynamic and persistant inside a nested ng-repeat with real time socket.io data updates
- Socketing for a Real-Time Django Application
- Get Socket Object by Id with node, redis-adapter and socket.io
- Node.js Socket.io seperate connection events for each page
- nodejs , socket.io simple code memory leak
- Is it possible to force Socket.io to use its Ajax fallback?
- Forward all messages to socket.io room
- Using Node.JS With ASP.NET WebForm and Socket.IO
- socket.io xhr post error on slow connection (3G mobile network)
Related Questions in LONG-POLLING
- Node.js with Socket.io - Long Polling fails and throws "code":1,"message":"Session ID unknown" response
- Google AppEngine channel is opened, client is receiving responses, but socket.onmessage is not being called
- Signalr - websocket successfully connected but client events only called with long pooling
- pushlet vs long polling as a push technology
- How can I push data to a browser where the data is based on a SQL statement?
- Does HTTP long polling support heartbeat message?
- Most suitable pushing technique for specific operation
- Atmosphere JS keeps sending get request after socket open
- nodejs longpoll socket hang up error
- Push notification server backend for iOS and Android Interval Poll methods
- Long-polling vs websocket when expecting one-time response from server-side
- Node.js long polling event loop breaks the whole code
- Koa 2 router how to make a long poll request
- Long polling with Httpclient
- How to session_write_close() in Laravel?
Related Questions in SERVER-PUSH
- Ajax reload method acting on a Django table
- How to implement receiving a server push in OkHttp?
- What's the best way to retrieve messages from the server for a chat application
- Did Facebook refreshes using ajax to get updates
- How to get UDP Server to push to Client when another Client sends to server
- Check server push support
- Examples of Push APIs
- how to implement server pushing when there is an update in mysql database?
- Can ASP.NET MVC's AsyncController be used to service large number of concurrent hanging requests (long poll)?
- Efficient server push through rails
- Redirect servlet async and heart beat
- Google Apps Calendar API Push Event Query
- Http Server Push with Netty + protobuf
- iphone push notifications using mosquitto
- A technology to push data from a server to a desktop Java application
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)
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?
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.