librelist archives

« back to archive

Re: NoMethodError: undefined method `write' for nil:NilClass

Re: NoMethodError: undefined method `write' for nil:NilClass

From:
Makoto Inoue
Date:
2009-12-22 @ 22:47
Hi,
I am resending this again, as I got the message that this email was dropped.

Thanks.

Makoto

On Tue, Dec 22, 2009 at 10:35 PM, Makoto Inoue <inouemak@googlemail.com> wrote:
> Hi
>
> I got to know your library through
> http://www.igvita.com/2009/12/22/ruby-websockets-tcp-for-the-browser/
>
> Thank you for sharing your interesting project.
>
> I tried to run it on my machine (Ruby 1.8.7), I tried to hit your
> sample code both from echo_client.py and Chromium browser, and got the
> following error for both.
>
> http://gist.github.com/262099
>
> Does your Sunshowers only work on Rurby1.9? Also, I am not sure how to
> "Make sure you’re using one of the following concurrency models for
> Rainbows". Would appreciate if you could expand the explanation.
>
> Thanks.
>
> Makoto
>

Re: [sunshowers] Re: NoMethodError: undefined method `write' for nil:NilClass

From:
Eric Wong
Date:
2009-12-22 @ 22:52
On Tue, Dec 22, 2009 at 10:35 PM, Makoto Inoue <inouemak@googlemail.com> wrote:
> Does your Sunshowers only work on Rurby1.9? Also, I am not sure how to
> "Make sure you’re using one of the following concurrency models for
> Rainbows". Would appreciate if you could expand the explanation.

Hi Makoto,

You need to use the Rainbows! web server for Sunshowers right now, since
we rely on a non-standard Rack extension.

You can read about Rainbows! here: http://rainbows.rubyforge.org/

It should work under 1.8 (ThreadSpawn/ThreadPool), but 1.9 is
recommended.

-- 
Eric Wong

Re: [sunshowers] Re: NoMethodError: undefined method `write' for nil:NilClass

From:
Makoto Inoue
Date:
2009-12-22 @ 22:58
Thanks.

I realised it right after I sent email. I am now installing Rainbow.

BTW, have you tried deploying sunshower based app to Heroku? That's
what I am currently trying to do.

Thanks.

Makoto

On Tue, Dec 22, 2009 at 10:52 PM, Eric Wong <normalperson@yhbt.net> wrote:
> On Tue, Dec 22, 2009 at 10:35 PM, Makoto Inoue <inouemak@googlemail.com> wrote:
>> Does your Sunshowers only work on Rurby1.9? Also, I am not sure how to
>> "Make sure you’re using one of the following concurrency models for
>> Rainbows". Would appreciate if you could expand the explanation.
>
> Hi Makoto,
>
> You need to use the Rainbows! web server for Sunshowers right now, since
> we rely on a non-standard Rack extension.
>
> You can read about Rainbows! here: http://rainbows.rubyforge.org/
>
> It should work under 1.8 (ThreadSpawn/ThreadPool), but 1.9 is
> recommended.
>
> --
> Eric Wong
>

Re: [sunshowers] Re: NoMethodError: undefined method `write' for nil:NilClass

From:
Eric Wong
Date:
2009-12-22 @ 23:02
Makoto Inoue <inouemak@googlemail.com> wrote:
> Thanks.
> 
> I realised it right after I sent email. I am now installing Rainbow.

Cool, let us know how it goes since it's barely used :)

> BTW, have you tried deploying sunshower based app to Heroku? That's
> what I am currently trying to do.

Nope, I've only tested on a few machines of my own and have never
used Heroku.

Btw, please don't top post here, thanks.

-- 
Eric Wong

Re: [sunshowers] Re: NoMethodError: undefined method `write' for nil:NilClass

From:
Makoto Inoue
Date:
2009-12-22 @ 23:17
On Tue, Dec 22, 2009 at 11:02 PM, Eric Wong <normalperson@yhbt.net> wrote:
>
> Cool, let us know how it goes since it's barely used :)
>

I was originally interested in WebSocket when I was playing with
node.js, a non blocking server side javascript library.
Here is my blog post.


http://blog.new-bamboo.co.uk/2009/12/7/real-time-online-activity-monitor-example-with-node-js-and-websocket

I posted my sample as a video, because I didn't want to keep paying
for hosting just for blog article.

I have been looking for Heroku deployable WebSocket server
implementation, so that I can put my demo for free, but looks I can
not :-(

WebSocket are now implmented in Erlang and GoogleGo as well, and I am
keen to benchmark all the solutions. If I manage to have my own
hosting, and do the comparison, I will definitely try Sunshowers +
Rainbow as well.

>
> Nope, I've only tested on a few machines of my own and have never
> used Heroku.
>
> Btw, please don't top post here, thanks.
>
> --
> Eric Wong
>

Didn't know what top post means till now.
Now I learnt it
http://www.idallen.com/topposting.html

:-)

Thanks.

Makoto

Re: [sunshowers] Re: NoMethodError: undefined method `write' for nil:NilClass

From:
Eric Wong
Date:
2009-12-22 @ 23:35
Makoto Inoue <inouemak@googlemail.com> wrote:
> I have been looking for Heroku deployable WebSocket server
> implementation, so that I can put my demo for free, but looks I can
> not :-(

The following patch might work for Mongrel if you're using rackup,
maybe this can work under Heroku (you can probably monkey patch it
in your application):

diff --git a/lib/rack/handler/mongrel.rb b/lib/rack/handler/mongrel.rb
index 7b44826..ab3d19b 100644
--- a/lib/rack/handler/mongrel.rb
+++ b/lib/rack/handler/mongrel.rb
@@ -57,6 +57,7 @@ module Rack
                      "rack.run_once" => false,
 
                      "rack.url_scheme" => "http",
+                     "hack.io" => response.socket,
                    })
         env["QUERY_STRING"] ||= ""
         env.delete "PATH_INFO"  if env["PATH_INFO"] == ""

-- 
Eric Wong

Re: [sunshowers] Re: NoMethodError: undefined method `write' for nil:NilClass

From:
Makoto Inoue
Date:
2009-12-23 @ 00:02
>
> The following patch might work for Mongrel if you're using rackup,
> maybe this can work under Heroku (you can probably monkey patch it
> in your application):
>
> diff --git a/lib/rack/handler/mongrel.rb b/lib/rack/handler/mongrel.rb
> index 7b44826..ab3d19b 100644
> --- a/lib/rack/handler/mongrel.rb
> +++ b/lib/rack/handler/mongrel.rb
> @@ -57,6 +57,7 @@ module Rack
>                      "rack.run_once" => false,
>
>                      "rack.url_scheme" => "http",
> +                     "hack.io" => response.socket,
>                    })
>         env["QUERY_STRING"] ||= ""
>         env.delete "PATH_INFO"  if env["PATH_INFO"] == ""
>
> --
> Eric Wong
>

Thank you for your patch. Heroku uses Thin and it uses Mongrel
Handler, so it may work, but probably I will hit more problems.
Probably I need my own hosting for living on the edge.

Re: [sunshowers] Re: NoMethodError: undefined method `write' for nil:NilClass

From:
Makoto Inoue
Date:
2009-12-24 @ 21:16
Hi, Eric.
Before patching Mongrel, I wanted to try SunShower a default setting.
To do so, I tried to run Rainbows, but it went crazy. Am I missing
anything obvious again?

Thanks.

Makoto

[rainbows]$ ruby -v
ruby 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0]
[rainbows]$ uname
Darwin
[rainbows]$ gem list rainbows
*** LOCAL GEMS ***
rainbows (0.90.0)
[rainbows]$ cat config.ru
require 'rainbows' # tried both with and without this statement.

worker_processes 2
Rainbows! do
  use :ThreadPool # Tried both ThreadPool and ThreadSpawn
  worker_connections 2
end

rainbows]$ rainbows
I, [2009-12-24T21:11:31.891885 #56596]  INFO -- : listening on
addr=0.0.0.0:8080 fd=3
I, [2009-12-24T21:11:31.893554 #56596]  INFO -- : worker=0 spawning...
I, [2009-12-24T21:11:31.895931 #56596]  INFO -- : master process ready
I, [2009-12-24T21:11:31.896280 #56597]  INFO -- : worker=0 spawned pid=56597
I, [2009-12-24T21:11:31.898612 #56597]  INFO -- : Refreshing Gem list
config.ru:3: undefined method `worker_processes' for
#<Rack::Builder:0x10252c328 @ins=[]> (NoMethodError)
	from /Library/Ruby/Gems/1.8/gems/rack-1.0.0/lib/rack/builder.rb:29:in
`instance_eval'
	from /Library/Ruby/Gems/1.8/gems/rack-1.0.0/lib/rack/builder.rb:29:in
`initialize'
	from config.ru:1:in `new'
	from config.ru:1
	from /Library/Ruby/Gems/1.8/gems/unicorn-0.95.3/lib/unicorn.rb:742:in `eval'
	from /Library/Ruby/Gems/1.8/gems/rainbows-0.90.0/bin/rainbows:131
	from /Library/Ruby/Gems/1.8/gems/unicorn-0.95.3/lib/unicorn.rb:742:in `call'
	from /Library/Ruby/Gems/1.8/gems/unicorn-0.95.3/lib/unicorn.rb:742:in
`build_app!'
	from /Library/Ruby/Gems/1.8/gems/unicorn-0.95.3/lib/unicorn.rb:597:in
`init_worker_process'
	from /Library/Ruby/Gems/1.8/gems/rainbows-0.90.0/lib/rainbows/base.rb:14:in
`init_worker_process'
	from /Library/Ruby/Gems/1.8/gems/unicorn-0.95.3/lib/unicorn.rb:612:in
`worker_loop'
	from /Library/Ruby/Gems/1.8/gems/unicorn-0.95.3/lib/unicorn.rb:531:in
`spawn_missing_workers'
	from /Library/Ruby/Gems/1.8/gems/unicorn-0.95.3/lib/unicorn.rb:531:in `fork'
	from /Library/Ruby/Gems/1.8/gems/unicorn-0.95.3/lib/unicorn.rb:531:in
`spawn_missing_workers'
	from /Library/Ruby/Gems/1.8/gems/unicorn-0.95.3/lib/unicorn.rb:527:in `each'
	from /Library/Ruby/Gems/1.8/gems/unicorn-0.95.3/lib/unicorn.rb:527:in
`spawn_missing_workers'
	from /Library/Ruby/Gems/1.8/gems/unicorn-0.95.3/lib/unicorn.rb:537:in
`maintain_worker_count'
	from /Library/Ruby/Gems/1.8/gems/unicorn-0.95.3/lib/unicorn.rb:215:in `start'
	from /Library/Ruby/Gems/1.8/gems/rainbows-0.90.0/lib/rainbows.rb:58:in `run'
	from /Library/Ruby/Gems/1.8/gems/rainbows-0.90.0/bin/rainbows:166
	from /usr/bin/rainbows:19:in `load'
	from /usr/bin/rainbows:19

Re: [sunshowers] Re: NoMethodError: undefined method `write' for nil:NilClass

From:
Eric Wong
Date:
2009-12-24 @ 21:20
Makoto Inoue <inouemak@googlemail.com> wrote:
> Hi, Eric.
> Before patching Mongrel, I wanted to try SunShower a default setting.
> To do so, I tried to run Rainbows, but it went crazy. Am I missing
> anything obvious again?
> 
> Thanks.
> 
> Makoto
> 
> [rainbows]$ cat config.ru
> require 'rainbows' # tried both with and without this statement.
> 
> worker_processes 2
> Rainbows! do
>   use :ThreadPool # Tried both ThreadPool and ThreadSpawn
>   worker_connections 2
> end

Hi Makato,

You're confusing config.ru with the Unicorn/Rainbows!-specific config
file.

config.ru is for your Rack application and may be used with any Rack
server.  The Unicorn/Rainbows! config file is separate (and what you
typed into config.ru instead).  There's no default path for a
Unicorn/Rainbows! config file, so you specify a path for it
with the '-c/--config-file' option.

-- 
Eric Wong

Re: [sunshowers] Re: NoMethodError: undefined method `write' for nil:NilClass

From:
Makoto Inoue
Date:
2009-12-24 @ 21:29
I didn't expect that you are going to reply this soon..... Thanks. Now
I am installing Unicorn.

So, to use SunShower, are there 2 ways?

A: Install Unicorn, Rainbow, and SunShower (+ Ruby 1.9 if I want to
use non Thread approach)
B: MonkeyPatch Mongrel (Do I need Unicorn for this? I hope not, as
Heroku does not have Unicorn. Heroku uses Thin, but Thin runs on top
of Mongrel request parser, so I am hoping that I can run on Heroku
once it's patched).

BTW, Python WebSocket now runs on Google App Engine (since about 10 hrs ago).


http://takashi-matsuo.blogspot.com/2009/12/integrating-websockets-with-appengine.html

Makoto

Re: [sunshowers] Re: NoMethodError: undefined method `write' for nil:NilClass

From:
Eric Wong
Date:
2009-12-24 @ 22:07
Makoto Inoue <inouemak@googlemail.com> wrote:
> I didn't expect that you are going to reply this soon..... Thanks. Now
> I am installing Unicorn.
> 
> So, to use SunShower, are there 2 ways?
> 
> A: Install Unicorn, Rainbow, and SunShower (+ Ruby 1.9 if I want to
> use non Thread approach)

Yes, the Rainbows! gem installation should've pulled in Unicorn already,
did it not?

> B: MonkeyPatch Mongrel (Do I need Unicorn for this? I hope not, as
> Heroku does not have Unicorn. Heroku uses Thin, but Thin runs on top
> of Mongrel request parser, so I am hoping that I can run on Heroku
> once it's patched).

I thought Heroku could use Mongrel directly, too.  No, you don't need
Unicorn for this.  Sunshowers currently does not work with Thin, but
maybe I can change that...

-- 
Eric Wong

Re: [sunshowers] Re: NoMethodError: undefined method `write' for nil:NilClass

From:
Makoto Inoue
Date:
2009-12-24 @ 22:20
Hi, Eric. Thank you again for your your reply.

> Yes, the Rainbows! gem installation should've pulled in Unicorn already,
> did it not?
>

It might have done it. Does executing "rainbows" command also invoke
Unicorn as well? When I invoke Unicorn, and  Rainbows separately, it
says "address already in use", because both Unicorn and Rainbows use
port 8081. If I just run rainbows, it still shows the same error
message as I had earlier.

> I thought Heroku could use Mongrel directly, too.  No, you don't need
> Unicorn for this.  Sunshowers currently does not work with Thin, but
> maybe I can change that...
>
They only say they use Nginx + Thin. Not sure if it's  switchable to Mongrel

http://docs.heroku.com/technologies

If you can change to work to Thin, that would be great.

Thanks.

Makoto

Re: [sunshowers] Re: NoMethodError: undefined method `write' for nil:NilClass

From:
Eric Wong
Date:
2009-12-24 @ 22:37
Makoto Inoue <inouemak@googlemail.com> wrote:
> Hi, Eric. Thank you again for your your reply.
> 
> > Yes, the Rainbows! gem installation should've pulled in Unicorn already,
> > did it not?
> 
> It might have done it. Does executing "rainbows" command also invoke
> Unicorn as well? When I invoke Unicorn, and  Rainbows separately, it
> says "address already in use", because both Unicorn and Rainbows use
> port 8081. If I just run rainbows, it still shows the same error
> message as I had earlier.

Rainbows! just uses Unicorn underneath, no need to start Unicorn
by itself.

> > I thought Heroku could use Mongrel directly, too.  No, you don't need
> > Unicorn for this.  Sunshowers currently does not work with Thin, but
> > maybe I can change that...
> >
> They only say they use Nginx + Thin. Not sure if it's  switchable to Mongrel
> 
> http://docs.heroku.com/technologies
> 
> If you can change to work to Thin, that would be great.

I'm trying to think of something. Give me a bit...

-- 
Eric Wong

Re: [sunshowers] Re: NoMethodError: undefined method `write' for nil:NilClass

From:
Makoto Inoue
Date:
2009-12-24 @ 23:06
On Thu, Dec 24, 2009 at 10:37 PM, Eric Wong <normalperson@yhbt.net> wrote:
> Makoto Inoue <inouemak@googlemail.com> wrote:
> Rainbows! just uses Unicorn underneath, no need to start Unicorn
> by itself.
>

Finally understood what you meant.
Here is my setting for both Rainbows and Sunshowers.

http://gist.github.com/263406

Tried this sample (changed port to 8080) on Chrome and working cool.


http://github.com/alexanderte/websocket-server-node.js/blob/master/echo-client.html

>> If you can change to work to Thin, that would be great.
>
> I'm trying to think of something. Give me a bit...
>
> --
> Eric Wong
>

No worries. Please take your time. It's Christmas Eve anyway. We
shouldn't even be touching computer!! It's 11pm GMT, so I am going to
bed now to wait for Santa.

Thank you very much for your patient guidance. I appreciated a lot!!

Cheers.

Makoto

Re: [sunshowers] Re: NoMethodError: undefined method `write' for nil:NilClass

From:
Makoto Inoue
Date:
2009-12-22 @ 23:01
Ah, I just learnt that Rainbow is a HTTP server, so I can't use it on
Heroku (which uses Thin)...

Thank you anyway.

Makoto

On Tue, Dec 22, 2009 at 10:58 PM, Makoto Inoue <inouemak@googlemail.com> wrote:
> Thanks.
>
> I realised it right after I sent email. I am now installing Rainbow.
>
> BTW, have you tried deploying sunshower based app to Heroku? That's
> what I am currently trying to do.
>
> Thanks.
>
> Makoto
>
> On Tue, Dec 22, 2009 at 10:52 PM, Eric Wong <normalperson@yhbt.net> wrote:
>> On Tue, Dec 22, 2009 at 10:35 PM, Makoto Inoue <inouemak@googlemail.com> wrote:
>>> Does your Sunshowers only work on Rurby1.9? Also, I am not sure how to
>>> "Make sure you’re using one of the following concurrency models for
>>> Rainbows". Would appreciate if you could expand the explanation.
>>
>> Hi Makoto,
>>
>> You need to use the Rainbows! web server for Sunshowers right now, since
>> we rely on a non-standard Rack extension.
>>
>> You can read about Rainbows! here: http://rainbows.rubyforge.org/
>>
>> It should work under 1.8 (ThreadSpawn/ThreadPool), but 1.9 is
>> recommended.
>>
>> --
>> Eric Wong
>>
>