#401 ActionController::Live pro
Server-sent events allow you to trigger events on the browser from a persistent connection to the server. This requires Rails stream data which can be done through ActionController::Live, a feature upcoming in Rails 4.



Frist!
On a serious note I was surprised you didn't mention your own gem 'private_pub'. (For which you have some pull-requests. One is actually quite good.
Anyway back on topic. I am currently running faye/private_pub in production and it has been doing relatively well. That said, my loads are pathetic. At most we have 50 users simultaneously using the system. Sometimes faye causes the browser to slow down ridiculously, at least on Chrome on Mac. Also messages get lost sometimes but I am not terribly worried about that. It's not critical data I am handling.
That said it just feels to me like the web has not been made for things like this. It feels like a dirty hackfest having to integrate 4 different pieces of software to make one thing more or less run. And this shows when you look at the hacky nature of what rails has done with it. I am used to rails being nice to use (not so much anymore. Rails got bloated... 'rbenv exec bundle exec rails c' great. real nice to type right?) but that controller just looks... ugly.
So I hope there will be a 'definate' solution to this problem in the future but I don't hold my hopes up.
Controller looks ugly? Move stuff to separate class.
Command is too long? Make an alias.
With a .rbenv-version file and bundler binstubs I just type bin/rails c. Which you can alias.
I think you're right about calling this a hack-fest. I think Ryan was alluding to that in the end, but covered it because it's a new core rails feature. But you have to keep in mind that if you need these services, you're going to have to integrate them somehow. I have found that Faye can be pretty fast, depending on your client side JS and architecture.
Stefano: use play with scala for websockets, or just use http://torquebox.org/features/
10x for the video!
Torquebox looks great! How easy is it to migrate? Is anyone using it in production?
Great topic, I waited for this a for a long time. Thanks!
One thing that I missing in this episode: Redis was described instead of PostgreSQL. Going to figure out how to do this with pgsql. Maybe this gem is applicable: https://github.com/ryandotsmith/queue_classic
Tried to implement this episode, it works!
Not such a big overhead adding Redis server.
Rails has to move in this direction.
If not it'll get obsolete in no time. With competition from meteor, backbone and all the other js frameworks, people start asking: "Why do I need this bloated Rails stuff?" The whole convention over configuration is a double-edged sword. Users shouldn't (and therefore don't) know about the trivial (but hard to solve on you own) questions.
For example Rails solves crsf with one line in the application_controller. Many other frameworks requires more configuration and because its hard to understand that leads to solutions like "- just disable crsf". In rails you don't have to think about the trivial stuff, just make your application.
The browsers to day is no longer dumb terminals. So, we have to make them work more trough javascript and JSON. Rails have to make better conventions for better handling JSON and open connections if we want to keep it relevant. If we keep on mainly sending rendered HTML down to a (stupid) web browser, rails soon be the old hog.
This episode shows that still it is to much configuration. The rails core team should make decisions. Code should be simple like this
+1
This episode makes me a little sad.
It's almost easier to setup Faye to handle this.
Excellent presentation, but its an excellent presentation of a kludge. After so many, "yes, but... no... do this.. but then that won't work the way it used to." twists, it is apparent that the problem wasn't with the pedagogy, but rather the feature itself.
Rails isn't ready for this solution, and I share with you the hope that new versions down the pike are more promising.
It might be worth checking out: http://www.pubnub.com/
I love the "theme" song :)
I'm personally excited for this, simply because the complexity of web sockets or comet always bothers me, whereas SSEs seem fairly straightforward. Its unfortunate that there are so many gotchas, but one could hope that, if not in the 4.0 release, a 4.0.1 or even a 4.1 would fix them
I may be wrong, but I think the postgresql listen/notify will require polling, too. So that's not really an option for "instant push".
This gist of mine shows where you have to SELECT null in order to get the socket to send along any unprocessed notifications, at which point you can get all notifications available on the connection.
https://gist.github.com/3915671#file-reel_ws_pg_example-rb-L21
Also, Tony Arcieri's reel is an excellent alternative in many respects to using live.
Do SSEs work on heroku. I ask because was looking into websockets on rails and heroku, but they don't support them.
Devise is almost ready to use with Rails (look at 'rails4' branch in its repository), but including
ActionController::Livecrashes the application.For the moment, solution is to move
eventsaction to separate controller.Does anyone know if it works with apache and passenger? I've been using it for a while.
How to use Puma by default: (by running just
rails sinsteadrails s puma): http://stackoverflow.com/questions/14146700/how-to-change-the-default-rails-server-in-rails-3/14911994#14911994Wow, great episode. Wanted to know more about that new feature for a while. Thanks!
Your opinion on this is correct, it's just not worth the effort because all of the restrictions on concurrent connections. After trying many possibilities (ActionController::Live, Socket.io, Faye,... ) we decided to outsource the real-time component entirely to pusher.com - highly recommended. It takes literally minutes to set up and you don't have to worry about updating, uptime, compatibilities, scaling...
(disclaimer: not affiliated to Pusher in any way)
Just thought I'd mention that !! works in bash, but it doesn't auto-expand like that. I wasn't aware of it... hopefully I don't forget before I have occasion to use it.
Does anyone know why has rails not adopted EventMachine? When i google around, i am unable to find any good concrete examples of usage of EM with Rails3.2. Would we have any out of the box compatibility from Rails4 for EM?
Are there any good reasons why psubscribe wouldn't work in the latest Rails4.rc1?
The rest of the tutorial's working a treat, I just cannot for the life of me figure out psub..
First sign in through GitHub to post a comment.