Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with "eventmachine not initialized" #119

Closed
lorensr opened this issue Sep 2, 2013 · 4 comments
Closed

Problem with "eventmachine not initialized" #119

lorensr opened this issue Sep 2, 2013 · 4 comments

Comments

@lorensr
Copy link

lorensr commented Sep 2, 2013

My connect call doesn't complete, and when I hit ctrl-c, I get the below message. Any recommendations on how I can further debug this? Thanks!

require 'blather/client'

Blather::Stream::Parser.debug = true

puts 'setup'
setup 'admin@localhost', 'password'

puts 'connecting...'
client.connect
puts 'done'

when_ready {
  write_to_stream Blather::Stanza::Message.new 'user@localhost', 'test msg'
}
$ r test.rb
setup:
connecting...
^C/usr/local/Cellar/ruby/2.0.0-p0/lib/ruby/gems/2.0.0/gems/eventmachine-1.0.3/lib/eventmachine.rb:664:in `connect_server': eventmachine not initialized: evma_connect_to_server (RuntimeError)
    from /usr/local/Cellar/ruby/2.0.0-p0/lib/ruby/gems/2.0.0/gems/eventmachine-1.0.3/lib/eventmachine.rb:664:in `bind_connect'
    from /usr/local/Cellar/ruby/2.0.0-p0/lib/ruby/gems/2.0.0/gems/eventmachine-1.0.3/lib/eventmachine.rb:640:in `connect'
    from /usr/local/Cellar/ruby/2.0.0-p0/lib/ruby/gems/2.0.0/gems/blather-0.8.7/lib/blather/stream.rb:112:in `connect'
    from /usr/local/Cellar/ruby/2.0.0-p0/lib/ruby/gems/2.0.0/gems/blather-0.8.7/lib/blather/stream.rb:101:in `block in start'
    from /usr/local/Cellar/ruby/2.0.0-p0/lib/ruby/gems/2.0.0/gems/blather-0.8.7/lib/blather/stream.rb:100:in `each'
    from /usr/local/Cellar/ruby/2.0.0-p0/lib/ruby/gems/2.0.0/gems/blather-0.8.7/lib/blather/stream.rb:100:in `detect'
    from /usr/local/Cellar/ruby/2.0.0-p0/lib/ruby/gems/2.0.0/gems/blather-0.8.7/lib/blather/stream.rb:100:in `start'
    from /usr/local/Cellar/ruby/2.0.0-p0/lib/ruby/gems/2.0.0/gems/blather-0.8.7/lib/blather/client/client.rb:100:in `run'
    from test.rb:11:in `<main>'
@benlangfeld
Copy link
Member

So, if you check out the example of a similar case, you don't need to call #connect at all since it's implicit, and certainly doing a blocking connect before setting up handlers is a bad idea. Let me know if you have any issues copying the example.

@lorensr
Copy link
Author

lorensr commented Sep 3, 2013

Thanks, I got it working, but then when I tried to switch to Facebook chat from my local ejabber server, it disconnects as soon as I send a message, and I don't see the message on the Facebook website. I'm using the same username and to: name that works successfully in iMessage. Any recommendations? For instance how to get the reason why the connection was closed?

require 'blather/client'

setup 'me@chat.facebook.com', 'app-specific password'

msg = Blather::Stanza::Message.new 'user@chat.facebook.com', 'test 1'

when_ready {
  puts 'ready'
  write_to_stream msg
  puts 'wrote'
}

disconnected {
  puts 'disconnected'
}

Gives

$ r test.rb
ready
wrote
disconnected

I'm pretty sure it's authenticating correctly, since when I make up a different password, the when_ready block isn't executed, and it disconnects.

@benlangfeld
Copy link
Member

Try running with -D to see log output. Also, I was under the
impression that Facebook required a different auth mechanism.

@lorensr
Copy link
Author

lorensr commented Sep 4, 2013

There are two Facebook chat XMPP auth methods. One is your username and an application-specific password, and the other is the app ID and app secret. Unless something jumps out at you from the below, I think I've hit a dead-end with the former and will try the latter next.

$ ruby -d test.rb
...
ready
<message to="[friend]@chat.facebook.com" type="chat">
  <body>test 1</body>
  <active xmlns="http://jabber.org/protocol/chatstates"/>
</message>
wrote
/usr/local/Cellar/ruby/2.0.0-p0/lib/ruby/gems/2.0.0/gems/blather-0.8.7/lib/blather/stream.rb:118: warning: instance variable @state not initialized
/usr/local/Cellar/ruby/2.0.0-p0/lib/ruby/gems/2.0.0/gems/blather-0.8.7/lib/blather/stream.rb:214: warning: instance variable @state not initialized
/usr/local/Cellar/ruby/2.0.0-p0/lib/ruby/gems/2.0.0/gems/blather-0.8.7/lib/blather/stream.rb:118: warning: instance variable @state not initialized
/usr/local/Cellar/ruby/2.0.0-p0/lib/ruby/gems/2.0.0/gems/blather-0.8.7/lib/blather/stream.rb:118: warning: instance variable @state not initialized
/usr/local/Cellar/ruby/2.0.0-p0/lib/ruby/gems/2.0.0/gems/blather-0.8.7/lib/blather/stream.rb:118: warning: instance variable @state not initialized
/usr/local/Cellar/ruby/2.0.0-p0/lib/ruby/gems/2.0.0/gems/blather-0.8.7/lib/blather/stream.rb:118: warning: instance variable @state not initialized
/usr/local/Cellar/ruby/2.0.0-p0/lib/ruby/gems/2.0.0/gems/blather-0.8.7/lib/blather/stream.rb:118: warning: instance variable @state not initialized
/usr/local/Cellar/ruby/2.0.0-p0/lib/ruby/gems/2.0.0/gems/blather-0.8.7/lib/blather/stream/features.rb:20: warning: instance variable @feature not initialized
/usr/local/Cellar/ruby/2.0.0-p0/lib/ruby/gems/2.0.0/gems/blather-0.8.7/lib/blather/stream/features.rb:35: warning: instance variable @idx not initialized
/usr/local/Cellar/ruby/2.0.0-p0/lib/ruby/gems/2.0.0/gems/blather-0.8.7/lib/blather/stream.rb:177: warning: instance variable @store not initialized
/usr/local/Cellar/ruby/2.0.0-p0/lib/ruby/gems/2.0.0/gems/blather-0.8.7/lib/blather/stream.rb:177: warning: instance variable @store not initialized
/usr/local/Cellar/ruby/2.0.0-p0/lib/ruby/gems/2.0.0/gems/blather-0.8.7/lib/blather/stream.rb:177: warning: instance variable @store not initialized
/usr/local/Cellar/ruby/2.0.0-p0/lib/ruby/gems/2.0.0/gems/blather-0.8.7/lib/blather/stream/features.rb:20: warning: instance variable @feature not initialized
/usr/local/Cellar/ruby/2.0.0-p0/lib/ruby/gems/2.0.0/gems/blather-0.8.7/lib/blather/stream/features.rb:35: warning: instance variable @idx not initialized
/usr/local/Cellar/ruby/2.0.0-p0/lib/ruby/gems/2.0.0/gems/blather-0.8.7/lib/blather/stream/features/sasl.rb:51: warning: instance variable @idx not initialized

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants