Starting gateway fails if message list is non-empty

166 views
Skip to first unread message

Ulugbek Baymuradov

unread,
Dec 27, 2011, 11:34:55 PM12/27/11
to ruby-smpp
Hi,

Gateway starts-up and sends messages fine, but when the message list
is non-empty, it fails. Here is my gateway config https://gist.github.com/1526274
and the rest of it is just like the example. This is the error I get
when gateway fails https://gist.github.com/1526296 . Any thoughts?

Thanks,

Bek

RayKrueger

unread,
Dec 28, 2011, 9:47:41 AM12/28/11
to ruby-smpp
> Gateway starts-up and sends messages fine, but when the message list
> is non-empty, it fails. Here is my gateway confighttps://gist.github.com/1526274
> and the rest of it is just like the example. This is the error I get
> when gateway failshttps://gist.github.com/1526296. Any thoughts?

Hi Bek,
I'm not sure what this UcellGateway class is, and you're not showing
me the class that is the delegate when we connect.

EventMachine::run do
@@tx = EventMachine::connect(
config[:host],
config[:port],
Smpp::Transceiver,
config,
self # delegate that will receive callbacks on MOs and
DRs and other events
)

That 'self' there is going to receive the bound and unbound method
calls. Implement those and add some logging to see that you're
connecting correctly.
That error you're getting is because the smpp bind never actually
managed to connect.

Have a look at the example gateway connection configuration for more
info.
https://github.com/raykrueger/ruby-smpp/blob/master/examples/sample_gateway.rb

Hope that helps!
Post back what you find :)

Ulugbek Baymuradov

unread,
Dec 28, 2011, 6:53:52 PM12/28/11
to ruby-smpp
Hi Ray,

UcellGateway was pretty much copy/paste version of sample_gateway.rb
from the examples. As you said, the error was happening because
transceiver hadn't yet connected to SMSC when sent_mt method is
called. The way I got it working was checking the state of transceiver
from @@tx.state and if the state is bound, then sending the message,
otherwise keep checking the state until it's bound.

@@tx = EventMachine::connect(
config[:host],
config[:port],
Smpp::Transceiver,
config,
self)
> info.https://github.com/raykrueger/ruby-smpp/blob/master/examples/sample_g...

Ray Krueger

unread,
Dec 28, 2011, 7:03:44 PM12/28/11
to ruby...@googlegroups.com
> UcellGateway was pretty much copy/paste version of sample_gateway.rb
> from the examples. As you said, the error was happening because
> transceiver hadn't yet connected to SMSC when sent_mt method is
> called. The way I got it working was checking the state of transceiver
> from @@tx.state and if the state is bound, then sending the message,
> otherwise keep checking the state until it's bound.
>
> @@tx = EventMachine::connect(
> config[:host],
> config[:port],
> Smpp::Transceiver,
> config,
> self)
>
Sounds like you're approaching this in a sort of round-a-bout way.
You could pass your UcellGateway as the delegate and in the "bound" call back start popping messages off your redis queue.

I'm not sure why you have EM stuff outside of that gateway class really.

Can you gist the solution you came up with?
Also the UcellGateway class?

Might be easier for me to show you what I'm thinking that way.

-Ray


Ulugbek Baymuradov

unread,
Dec 28, 2011, 7:14:01 PM12/28/11
to ruby...@googlegroups.com
Here is the gist https://gist.github.com/1530609

Bek

RayKrueger

unread,
Dec 29, 2011, 12:23:56 PM12/29/11
to ruby-smpp
> Here is the gisthttps://gist.github.com/1530609

Alright, took a stab at approaching this a bit differently.
https://gist.github.com/1534951

I didn't actually try running this, but it's where I'd start.

Let me know if that helps.

RayKrueger

unread,
Dec 29, 2011, 12:29:27 PM12/29/11
to ruby-smpp
> > Here is the gisthttps://gist.github.com/1530609
>
> Alright, took a stab at approaching this a bit differently.https://gist.github.com/1534951
>
> I didn't actually try running this, but it's where I'd start.
>
> Let me know if that helps.

Just updated it :)
https://gist.github.com/1534951

Mainly I removed the loop inside start(config). I'd suggest running
with something like God or Monit that can restart it when it dies
rather than just looping.

Ulugbek Baymuradov

unread,
Dec 30, 2011, 9:21:58 AM12/30/11
to ruby...@googlegroups.com
Thanks for the gist, code looks much more elegant than mine. However, there seems to be a problem with redis method. Gateway keeps running, but messages don't get sent. When I send CTL+C, suddenly everything gets sent and .rb file stops, which I thought was interesting. I called puts "#{redis.inspect}" and seems like @connected is false. Fundamentally, there doesn't seem to be any difference between how you and I are using redis method. Perhaps redis is taking longer to connect or maybe initially @redis is stuck with disconnected status and never being checked?

Bek

D, [2011-12-30T05:13:57.371645 #13492] DEBUG -- : Bound OK.
E, [2011-12-30T05:14:34.247657 #13492] ERROR -- : Error receiving data:
/home/vagrant/.rvm/gems/ruby-1.9.2-p290/gems/eventmachine-0.12.10/lib/em/deferrable.rb:50:in `callback'
/home/vagrant/.rvm/gems/ruby-1.9.2-p290/gems/em-hiredis-0.1.0/lib/em-hiredis/client.rb:155:in `method_missing'
/vagrant/lib/ruby-smpp/gateways/ucellgate.rb:123:in `process_messages'
/vagrant/lib/ruby-smpp/gateways/ucellgate.rb:90:in `bound'
/vagrant/lib/ruby-smpp/lib/smpp/base.rb:178:in `process_pdu'
/vagrant/lib/ruby-smpp/lib/smpp/base.rb:109:in `receive_data'
/home/vagrant/.rvm/gems/ruby-1.9.2-p290/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine'
/home/vagrant/.rvm/gems/ruby-1.9.2-p290/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run'
/vagrant/lib/ruby-smpp/gateways/ucellgate.rb:72:in `start'
/vagrant/lib/ruby-smpp/gateways/ucellgate.rb:301:in `<main>'

#<EventMachine::Hiredis::Client:0x9a3763c @db="0", @password=nil, @port=6379, @host="127.0.0.1", @subs=[], @psubs=[], @defs=[], @connection=#<EventMachine::Hiredis::Connection:0x9a374fc @signature=4, @host="127.0.0.1", @port=6379, @_listeners={:closed=>[#<Proc:0x9a3745c@/home/vagrant/.rvm/gems/ruby-1.9.2-p290/gems/em-hiredis-0.1.0/lib/em-hiredis/client.rb:22>], :connected=>[#<Proc:0x9a373bc@/home/vagrant/.rvm/gems/ruby-1.9.2-p290/gems/em-hiredis-0.1.0/lib/em-hiredis/client.rb:35>], :message=>[#<Proc:0x9a37380@/home/vagrant/.rvm/gems/ruby-1.9.2-p290/gems/em-hiredis-0.1.0/lib/em-hiredis/client.rb:51>]}>, @connected=false, @reconnecting=false>

Ray Krueger

unread,
Dec 30, 2011, 10:03:36 AM12/30/11
to ruby...@googlegroups.com

> Thanks for the gist, code looks much more elegant than mine. However, there seems to be a problem with redis method. Gateway keeps running, but messages don't get sent. When I send CTL+C, suddenly everything gets sent and .rb file stops, which I thought was interesting. I called puts "#{redis.inspect}" and seems like @connected is false. Fundamentally, there doesn't seem to be any difference between how you and I are using redis method. Perhaps redis is taking longer to connect or maybe initially @redis is stuck with disconnected status and never being checked?
>
> Bek
Yeah, I was n't sure how well that was going to work. That while @bound loop is likely a bad idea :)
Maybe go back to that EM.next_tick stuff you were trying before? I'd use the "bound" call back to schedule the first one and go from there.

Reply all
Reply to author
Forward
0 new messages