Saturday, July 31, 2010

No, Actually Faye Loves Chrome on Linux

‹prev | My Chain | next›

I love being part of the developer community, even if only a small part. I love that there are smart, interesting people doing smart interesting things out there. Not only do I get to hear about what they are doing, but I get to play with the toys that they find fascinating. And, best of all, when I have problems, these same passionate people are actually willing—eager even—to give me pointers as to what I am doing wrong.

For the life of me, I could not get faye work with the latest Chrome. Faye is a pub/sub framework with backends written in both ruby and node.js (I was using the latter). Finally, I submitted a issue on the github issue tracker for faye. Less than two hours later, I had a response and, better still, an explanation.

The latest development versions of Chrome (I am using 6.0.472.11) support a newer version of the websockets working draft, specifically draft 76. Faye does not support anything that is not in a stable, in-production browser. Chrome 6 is a developer series, so I am out of luck. Except I am not because James Coglan has already started work on draft 76 in the ws-draft76 branch of faye.

Let's see if I can resolve my woes on that branch. First up, I need to install jake (it's like make, but for Javascript) to build the package for npm:
cstrom@whitefall:~/repos$ gem install jake
Successfully installed methodphitamine-1.0.0
Successfully installed eventful-1.0.0
Successfully installed oyster-0.9.4
Successfully installed packr-3.1.0
Successfully installed jake-1.0.1
5 gems installed
Then, I clone faye:
cstrom@whitefall:~/repos$ git clone http://github.com/jcoglan/faye.git
Initialized empty Git repository in /home/cstrom/repos/faye/.git/
remote: Counting objects: 2774, done.
remote: Compressing objects: 100% (1105/1105), done.
remote: Total 2774 (delta 1714), reused 2624 (delta 1572)
Receiving objects: 100% (2774/2774), 484.85 KiB | 161 KiB/s, done.
Resolving deltas: 100% (1714/1714), done.
And switch to the ws-draft76 branch:
cstrom@whitefall:~/repos/faye$ gba
* master
remotes/origin/0.3.x
remotes/origin/HEAD -> origin/master
remotes/origin/clients
remotes/origin/cometd-compat
remotes/origin/daemon
remotes/origin/extensions
remotes/origin/jetty-test
remotes/origin/master
remotes/origin/moot-debug
remotes/origin/multiple-subscriptions
remotes/origin/node
remotes/origin/ssl
remotes/origin/websockets
remotes/origin/ws-draft76
cstrom@whitefall:~/repos/faye$ git co ws-draft76
Branch ws-draft76 set up to track remote branch ws-draft76 from origin.
Switched to a new branch 'ws-draft76'
Finally, I build the package with jake:
cstrom@whitefall:~/repos/faye$ jake
/home/cstrom/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- em-http (LoadError)
from /home/cstrom/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /home/cstrom/repos/faye/lib/faye/network/transport.rb:1
from /home/cstrom/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /home/cstrom/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from ./lib/faye.rb:34
from ./lib/faye.rb:20:in `each'
from ./lib/faye.rb:20
from /home/cstrom/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /home/cstrom/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /home/cstrom/repos/faye/Jakefile:1
from /home/cstrom/.rvm/gems/ruby-1.8.7-p249/gems/jake-1.0.1/bin/../lib/jake/build.rb:27:in `load'
from /home/cstrom/.rvm/gems/ruby-1.8.7-p249/gems/jake-1.0.1/bin/../lib/jake/build.rb:27:in `initialize'
from /home/cstrom/.rvm/gems/ruby-1.8.7-p249/gems/jake-1.0.1/bin/jake:33:in `new'
from /home/cstrom/.rvm/gems/ruby-1.8.7-p249/gems/jake-1.0.1/bin/jake:33
from /home/cstrom/.rvm/gems/ruby-1.8.7-p249/bin/jake:19:in `load'
from /home/cstrom/.rvm/gems/ruby-1.8.7-p249/bin/jake:19
Hrm... I must need to install another gem:
cstrom@whitefall:~/repos/faye$ gem install em-http
ERROR: could not find gem em-http locally or in a repository
cstrom@whitefall:~/repos/faye$ gem install em-http-request
Building native extensions. This could take a while...
Successfully installed em-http-request-0.2.10
1 gem installed
But even with that installed, I am still getting missing gem errors. Eventually , I read the instructions at the fay github page and:
cstrom@whitefall:~/repos/faye$ gem install hoe eventmachine em-http-request rack thin json
With that, I can successfully run jake, though now it barfs on the Jakefile:
cstrom@whitefall:~/repos/faye$ jake
core src /build/core.js UP-TO-DATE
core min /build/core-min.js 15 kB
faye-browser src /build/faye-browser.js 56 kB
faye-browser min /build/faye-browser-min.js 23 kB
faye-node src /build/faye-node.js 57 kB
faye-node min /build/faye-node-min.js 30 kB
/home/cstrom/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/fileutils.rb:1201:in `stat': No such file or directory - README.txt (Errno::ENOENT)
from /home/cstrom/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/fileutils.rb:1201:in `lstat'
from /home/cstrom/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/fileutils.rb:1179:in `stat'
from /home/cstrom/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/fileutils.rb:1261:in `copy_file'
from /home/cstrom/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/fileutils.rb:463:in `copy_file'
from /home/cstrom/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/fileutils.rb:383:in `cp'
from /home/cstrom/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/fileutils.rb:1396:in `fu_each_src_dest'
from /home/cstrom/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/fileutils.rb:1412:in `fu_each_src_dest0'
from /home/cstrom/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/fileutils.rb:1394:in `fu_each_src_dest'
from /home/cstrom/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/fileutils.rb:382:in `cp'
from /home/cstrom/repos/faye/Jakefile:13
...
To workaround this, I simply copy the README.rdoc to README.txt (they seem to be identical when compared to the version installed via npm). Now, I can build and install the ws-draft76 version of faye:
cstrom@whitefall:~/repos/faye$ jake
core src /build/core.js 30 kB
core min /build/core-min.js 15 kB
faye-browser src /build/faye-browser.js UP-TO-DATE
faye-browser min /build/faye-browser-min.js UP-TO-DATE
faye-node src /build/faye-node.js 57 kB
faye-node min /build/faye-node-min.js 30 kB
cstrom@whitefall:~/repos/faye$ cd build/
cstrom@whitefall:~/repos/faye/build$ ls
faye-browser.js faye-browser-min.js faye-node.js History.txt package.json README.txt
cstrom@whitefall:~/repos/faye/build$ npm install .
The "ini" module will be removed in future versions of Node, please extract it into your own code.
npm configfile /home/cstrom/.npmrc
npm sudo false
npm cli [ 'install', '.' ]
npm install pkg .
...
npm activate faye 0.5.1
npm readJson /home/cstrom/.node_libraries/.npm/faye/active/package/package.json
npm readJson /home/cstrom/.node_libraries/.npm/faye/0.5.1/package/package.json
npm testEngine required: node ">=0.1.96"
npm build Success: faye-0.5.1
npm ok
Yay!

With that, all that is left it to try out my faye backend:



The backend (written in fab.js) and frontend code is still the identical to what I wrote the other night. The subscriptions to the faye channels simply console.debug any message received. As can be seen in the video, I can publish and receive messages from Firefox, Chrome 6.x, and, from another machine, using an older Chrome (5.x). Thus I know that my (fab) faye backend works with long polling, web sockets draft 76 and draft 75.

I stop there for the night, quite content. A big thanks to James Coglan not only for writing faye in the first place, but also for doing an outstanding job supporting it!


Day #181

No comments:

Post a Comment