# File lib/brb/event_machine.rb, line 29
      def open(uri, klass, opts = {})
        host, port = parse_uri(uri)
        begin
          ensure_em_is_started!
      
          q = Queue.new
          EM.schedule do
            q << EM::connect(host, port, klass, opts.merge(:uri => "brb://#{host}:#{port}"))
          end
          
          # Wait for socket connection with the q.pop

          return q.pop

        rescue Exception => e
          BrB.logger.error e.backtrace.join("\n")
          raise "#{e} - #{uri}"
        end
      end