Mark Van De Vyver
2007-May-07 22:27 UTC
[Eventmachine-talk] Two examples not running as expected
Hi, I''m having some trouble running two EM examples. I''m using the EM gem version 0.7.0 ruby --version: ruby 1.8.5 (2006-08-25) [i586-linux] Operating system: uname -a: Linux mv-laptop 2.6.18.8-0.1-default #1 SMP Fri Mar 2 13:51:59 UTC 2007 i686 i686 i386 GNU/Linux the code example is below. I have inserted my IP address, as shown by ifconfig -a. If I use the code as below the ruby console is empty. # ###### start code snippet ###### require ''rubygems'' require ''eventmachine'' module EchoServer def receive_data data send_data ">>>you sent: #{data}" close_connection if data =~ /quit/i end end EventMachine::run { EventMachine::start_server "192.168.1.1", 8100, EchoServer } # ###### end code snippet ###### If I use the port 8081 I get the following in the ruby console: /usr/lib/ruby/gems/1.8/gems/eventmachine-0.7.0/lib/eventmachine.rb:445:in `start_tcp_server'': no acceptor (RuntimeError) from /usr/lib/ruby/gems/1.8/gems/eventmachine-0.7.0/lib/eventmachine.rb:445:in `start_server'' from lib/em_example.rb:12 from /usr/lib/ruby/gems/1.8/gems/eventmachine-0.7.0/lib/eventmachine.rb:791:in `call'' from /usr/lib/ruby/gems/1.8/gems/eventmachine-0.7.0/lib/eventmachine.rb:791:in `event_callback'' from /usr/lib/ruby/gems/1.8/gems/eventmachine-0.7.0/lib/eventmachine.rb:201:in `run_machine'' from /usr/lib/ruby/gems/1.8/gems/eventmachine-0.7.0/lib/eventmachine.rb:201:in `run'' from lib/em_example.rb:11 I have also tried to run the code example shown in this post: http://rubyforge.org/pipermail/eventmachine-talk/2006-May/000060.html When I do, all I see in the console is (spaced 5 seconds apart): [] [] [] ..... I have tried the above two examples using 127.0.0.1 and a fully qualified domain name - all give the same result. Any suggestions about what I might have done or configured incorrectly? Thanks in advance Mark
Mark Van De Vyver
2007-May-07 23:27 UTC
[Eventmachine-talk] Two examples not running as expected
Hi, Please disregard the email below. I''ve worked out what my mistake was - all works as expected! Apologies for the mail clutter Mark On 5/8/07, Mark Van De Vyver <mvyver at gmail.com> wrote:> Hi, > I''m having some trouble running two EM examples. > I''m using the EM gem version 0.7.0 > ruby --version: > ruby 1.8.5 (2006-08-25) [i586-linux] > > Operating system: > uname -a: > Linux mv-laptop 2.6.18.8-0.1-default #1 SMP Fri Mar 2 13:51:59 UTC > 2007 i686 i686 i386 GNU/Linux > > the code example is below. I have inserted my IP address, as shown by > ifconfig -a. > If I use the code as below the ruby console is empty. > > # ###### start code snippet ###### > > require ''rubygems'' > require ''eventmachine'' > > module EchoServer > def receive_data data > send_data ">>>you sent: #{data}" > close_connection if data =~ /quit/i > end > end > > EventMachine::run { > EventMachine::start_server "192.168.1.1", 8100, EchoServer > } > > # ###### end code snippet ###### > > If I use the port 8081 I get the following in the ruby console: > > /usr/lib/ruby/gems/1.8/gems/eventmachine-0.7.0/lib/eventmachine.rb:445:in > `start_tcp_server'': no acceptor (RuntimeError) > from /usr/lib/ruby/gems/1.8/gems/eventmachine-0.7.0/lib/eventmachine.rb:445:in > `start_server'' > from lib/em_example.rb:12 > from /usr/lib/ruby/gems/1.8/gems/eventmachine-0.7.0/lib/eventmachine.rb:791:in > `call'' > from /usr/lib/ruby/gems/1.8/gems/eventmachine-0.7.0/lib/eventmachine.rb:791:in > `event_callback'' > from /usr/lib/ruby/gems/1.8/gems/eventmachine-0.7.0/lib/eventmachine.rb:201:in > `run_machine'' > from /usr/lib/ruby/gems/1.8/gems/eventmachine-0.7.0/lib/eventmachine.rb:201:in > `run'' > from lib/em_example.rb:11 > > I have also tried to run the code example shown in this post: > http://rubyforge.org/pipermail/eventmachine-talk/2006-May/000060.html > > When I do, all I see in the console is (spaced 5 seconds apart): > [] > [] > [] > ..... > > I have tried the above two examples using 127.0.0.1 and a fully > qualified domain name - all give the same result. > Any suggestions about what I might have done or configured incorrectly? > > Thanks in advance > Mark >
Mark Van De Vyver
2007-Jun-01 17:33 UTC
[Eventmachine-talk] Two examples not running as expected
Hi Eugueny, (cc list) Good question. Took me some time to think back.... I''ve taken the liberty of cc''ing the list in case anyone else comes along this ''path''/thread. I think this is what happened. Regarding my first mail in this thread: The error message was (I think) due to the port being in use(?) Regarding: http://rubyforge.org/pipermail/eventmachine-talk/2006-May/000060.html Well. I understood so little of what was happening in EM that what I thought was unexpected behavior was, in fact, perfect behavior... The sequence of printed ''[]'' reflect the fact that no client has yet connected to that server :) The following example helped me work out what was happening. From this I added snippets from the code in http://rubyforge.org/pipermail/eventmachine-talk/2006-May/000060.html I hope the following helps? #### Start server code #### # #Start an instance of irb in a new shell # $stderr.sync = $stdout.sync = true require ''rubygems'' require ''eventmachine'' module EchoServer def receive_data data puts "Server received: #{data}" send_data ">>>you sent: #{data}" puts "Server sent: >>>you sent: #{data}" close_connection if data =~ /quit/i end end EventMachine::run { EventMachine::start_server "192.168.1.1", 8100, EchoServer } #### End server code #### #### Start client code #### # #Start another instance of irb in a new shell # $stderr.sync = $stdout.sync = true require ''rubygems'' require ''eventmachine'' class EchoClient < EventMachine::Connection def receive_data data puts "Client Received: #{data}" close_connection if data =~ /quit/i end end cnt=0 EventMachine::run { emc = EventMachine::connect "192.168.1.1", 8100, EchoClient EventMachine.add_periodic_timer(5) {cnt +=1; emc.send_data "Message: #{cnt}"} } #### End client code #### On 6/1/07, Eugueny Kontsevoy <....> wrote:> Howdy, > > I googled your post: > http://rubyforge.org/pipermail/eventmachine-talk/2007-May/000695.html > > and I just ran into the same issue and must admit: I stuck. What was it in > your case, if you don''t mind sharing? > thank you. > >On 5/8/07, Mark Van De Vyver <mvyver at gmail.com> wrote:> Hi, > Please disregard the email below. > I''ve worked out what my mistake was - all works as expected! > Apologies for the mail clutter > Mark > > > > On 5/8/07, Mark Van De Vyver <mvyver at gmail.com> wrote: > > Hi, > > I''m having some trouble running two EM examples. > > I''m using the EM gem version 0.7.0 > > ruby --version: > > ruby 1.8.5 (2006-08-25) [i586-linux] > > > > Operating system: > > uname -a: > > Linux mv-laptop 2.6.18.8-0.1-default #1 SMP Fri Mar 2 13:51:59 UTC > > 2007 i686 i686 i386 GNU/Linux > > > > the code example is below. I have inserted my IP address, as shown by > > ifconfig -a. > > If I use the code as below the ruby console is empty. > > > > # ###### start code snippet ###### > > > > require ''rubygems'' > > require ''eventmachine'' > > > > module EchoServer > > def receive_data data > > send_data ">>>you sent: #{data}" > > close_connection if data =~ /quit/i > > end > > end > > > > EventMachine::run { > > EventMachine::start_server "192.168.1.1", 8100, EchoServer > > } > > > > # ###### end code snippet ###### > > > > If I use the port 8081 I get the following in the ruby console: > > > > /usr/lib/ruby/gems/1.8/gems/eventmachine-0.7.0/lib/eventmachine.rb:445:in > > `start_tcp_server'': no acceptor (RuntimeError) > > from /usr/lib/ruby/gems/1.8/gems/eventmachine-0.7.0/lib/eventmachine.rb:445:in > > `start_server'' > > from lib/em_example.rb:12 > > from /usr/lib/ruby/gems/1.8/gems/eventmachine-0.7.0/lib/eventmachine.rb:791:in > > `call'' > > from /usr/lib/ruby/gems/1.8/gems/eventmachine-0.7.0/lib/eventmachine.rb:791:in > > `event_callback'' > > from /usr/lib/ruby/gems/1.8/gems/eventmachine-0.7.0/lib/eventmachine.rb:201:in > > `run_machine'' > > from /usr/lib/ruby/gems/1.8/gems/eventmachine-0.7.0/lib/eventmachine.rb:201:in > > `run'' > > from lib/em_example.rb:11 > > > > I have also tried to run the code example shown in this post: > > http://rubyforge.org/pipermail/eventmachine-talk/2006-May/000060.html > > > > When I do, all I see in the console is (spaced 5 seconds apart): > > [] > > [] > > [] > > ..... > > > > I have tried the above two examples using 127.0.0.1 and a fully > > qualified domain name - all give the same result. > > Any suggestions about what I might have done or configured incorrectly? > > > > Thanks in advance > > Mark > > >
Francis Cianfrocca
2007-Jun-01 19:13 UTC
[Eventmachine-talk] Two examples not running as expected
Sounds like you did figure it out Mark, but I wanted to point out one thing about the "no acceptor" error. It''s actually one of the more straightforward errors, and it essentially *always* means either that you used an IP address that isn''t defined on that machine, or you aren''t privileged enough to open the port, or it''s already open in another process. There aren''t any other realistic possibilities. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/eventmachine-talk/attachments/20070601/b271429f/attachment.html