Ejabberd and Xmpp on EC2. Connection Timeout

I have been working on Ejabberd and Orbited for our Rails application for over 5 months and have installed and managed our servers (most of which run on the Amazon EC2 setup) for a while now, but my last installation left me stumped. The thing was my installation would go through perfectly and I would be able to access my ejabberd admin console on 5280 perfectly but was unable to connect to it through the console.

I would create my client and the connect call would wait forever before timing out

client= Jabber::Client.new(Jabber::JID.new("admin@jabber.example.com"))
client.connect
Errno::ETIMEDOUT: Connection timed out - connect(2)
  from
/usr/lib/ruby/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/connection.rb:66:in
`initialize'
  from
/usr/lib/ruby/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/connection.rb:66:in
`new'
  from
/usr/lib/ruby/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/connection.rb:66:in
`connect'
  from /usr/lib/ruby/gems/1.8/gems/xmpp4r-0.5/lib/xmpp4r/client.rb:70:in
`connect'
  from (irb):4

I tried reinstalling and looked everywhere I could have possibly goofed up.

The solution to the problem was on EC2 and not the installation. Its actually an EC2 security groups issue. You need to ensure for the instance your working with, if the security group has port 5222 and if your working with server-2-server 5269 open.

The way to get this done using elastic fox is

  • click on the instance you want the port to be open
  • click on the security groups tab
  • click on the group permissions -> grant permissions button (green button with a tick mark) which would open a popup box
  • add the port (in the port field) 5222.
  • Add 0.0.0.0/0 for hosts to allow all.

Repeat the process and add it for 5269 if your working with server-2-server and your done.

Hope this is useful to someone.