eventmachine

What causes EventMachine::ConnectionNotBound?

I'm new to EventMachine, so I'm not sure what this means. I'm getting this exception: EventMachine::ConnectionNotBound recieved ConnectionUnbound for an unknown signature: ef93a97d4d6441cb80d30fe2313d7de73 The program is fairly complicated, so I can't really explain everything that might have led up to it. All I need is a pointer to...

Sharing DB connections across objects using class methods in ruby?

Hello, I am writing a ruby script to be used as Postfix SMTP access policy delegation. The script needs to access a Tokyo Tyrant database. I am using EventMachine to take care of network connections. EventMachine needs a EventMachine::Connection class that is instantiated by EventMachine‘s processing loop whenever a new connection is cr...

JRuby EventMachine no such file to load

I have intalled EventMachine in JRuby (I am using Win32). When I try the server example, I get an error when require 'eventmachine' The error is: C:\dev\em>jruby server.rb server.rb:1:in `require': no such file to load -- eventmachine (LoadError) from server.rb:1 But the gem is installed! C:\dev\myapp>jruby -S gem instal...

SOAP calls using EventMachine

Is there any way to make non-blocking SOAP requests within EventMachine? I'm creating a ruby application which interacts with the google adwords api (which is SOAP based), using the adwords4r gem. The application uses EM to receive messages over a stomp connection, and then processes those messages by making SOAP calls to the adwords a...

EventMachine : How to build a chat system with Rails application

I am building a chat system using EventMachine and ruby on rails. It's for learning purpose. This is how client is connecting to server. c = TCPSocket.open(ip_address, port) data = {:user_id => 2, :message => 'hello world'} c.send(data) response = c.gets c.close It works. However the problem is that I can't get the list of people who...

Executing large numbers of asynchronous IO-bound operations in Rails

I'm working on a Rails application that periodically needs to perform large numbers of IO-bound operations. These operations can be performed asynchronously. For example, once per day, for each user, the system needs to query Salesforce.com to fetch the user's current list of accounts (companies) that he's tracking. This results in hu...

How to hand-over a TCP listening socket with minimal downtime?

While this question is tagged EventMachine, generic BSD-socket solutions in any language are much appreciated too. Some background: I have an application listening on a TCP socket. It is started and shut down with a regular System V style init script. My problem is that it needs some time to start up before it is ready to service th...

eventmachine and external scripts via backticks

I have a small HTTP server script I've written using eventmachine which needs to call external scripts/commands and does so via backticks (``). When serving up requests which don't run backticked code, everything is fine, however, as soon as my EM code executes any backticked external script, it stops serving requests and stops executing...

Flash communication options for 2-player-games

I am currently working on a project that embeds a flash game, that uses Smartfoxserver for the flash communication. That communication is mostly just synchronizing the cursor and object movements between the two players. Since I am not a flash guy, but a ruby programmer, I got curious: What kind of communication options does flash offer...

Eventmachine:recieved ConnectionUnbound for an unknown signature

While I start server in Fedora 12, a client in Ubuntu 9.10.The client receive this error message. But it's OK while I start server in Ubuntu 9.10, a client in Fedora 12. I alreadt shutdown the FireWall. ...

What is the best way to read files in an EventMachine-based app?

In order not to block the reactor I would like to read files asynchronously, but I've found no obvious way of doing it using EventMachine. I've tried a few different approaches, but none of them feels right: Just read the file, it'll block the reactor, but what the hell, it's not that slow (unless it's a big file, and then it definitel...

What is the point/purpose of Ruby EventMachine, Python Twisted, or JavaScript Node.js?

I don't understand what problem these frameworks solve. Are they replacements for a HTTP server like Apache HTTPD, Tomcat, Mongrel, etc? Or are they more? Why might I use them... some real world examples? I've seen endless examples of chat rooms and broadcast services, but don't see how this is any different than, for instance, setti...

Any success with Sinatra working together with EventMachine WebSockets?

I have been using Sinatra for sometime now and I would like to add some realtime features to my web-app by pushing the data via websockets. I have successfully used the gem 'em-websocket' on its own, but have not been able to write one ruby file that has a sinatra web server AND a web-socket server. I've tried spinning the run! or star...

EventMachine occasionally fails to perform get_peername

In order to retrieve peer IP and port, you usually need to call Socket.unpack_sockaddr_in(get_peername), but I noticed that it leads to sporadic crashes because get_peername returns nil in callbacks like post_init or even in receive_data. Is that an expected behavior? If so, what callback would be the right place to save the peername in...

Why Eventmachine Defer slower than Ruby Thread?

I have two scripts which using mechanize to fetch google index page. I assuming Eventmachine will faster than ruby thread, but not. Eventmachine code cost "0.24s user 0.08s system 2% cpu 12.682 total" Ruby Thread code cost "0.22s user 0.08s system 5% cpu 5.167 total " Am I use eventmachine in wrong way? Who can explain it to me, ...

Eventmachine / Em-http-request / SQL throughput and architecture

I'm trying to create some code to process the twitter spritzer stream, and from the advice I'd found it seem like using ruby's eventmachine/em-http-request is a good way to do it. The basic code is below, and I'm getting ok performance, but I don't believe its able to keep up with the stream (despite running on a fairly well spec'd AWS ...

Getting async http requests to work on rails 3beta4/ruby 1.9.2-rc2/thin/eventmachine

I've been trying to get basic async HTTP calls to work in my app. I've tried using some code in my app from the Rails 3 async stack demo: http://github.com/igrigorik/async-rails, but I'm getting "can't yield from root fiber" and I have no idea where to go from here. Here's the top of my trace: (eval):10:in `yield' (eval):10:in `get' a...

Working examples of EM::Iterator

Does anyone have any working examples of EM::Iterator? The only examples I can find seem to be copies of (or point back to): http://yardoc.org/docs/eventmachine-eventmachine/EventMachine/Iterator I don't see any instances of EM::Iterator in EventMachine's Rdoc, so I'm not sure if it's an old class that has been removed or not. I gen...

Need a ruby solution for executing a method in separate process.

I am implementing a poller service whose interface looks like this. poller = Poller.new(SomeClass) poller.start poller.stop The start method is supposed to continuously start hitting an http request and update stuff in the database. Once started, the process is supposed to continue till it is explicitly stoped. I understand that imp...

Good library/platform for a real-time/parallel HTTP crawler?

I am building a crawler that fetches information in parallel from a number of websites in real-time in response to a request for this information from a client. I need to request specific pages from 10-20 websites, parse their contents for specific snippets of information and return this information to the client as fast as possible. I w...