I am a long time user of backgroundrb, and have used it''s server methods (start_server and connect) to communicate data between various servers and applications. It has been a great tool for this, and I feel fairly comfortable with how the server and client communicate. With the latest version, however, I have encountered some problems. I can successfully connect with ''connect'' to a server started with ''start_server'', and the post_init function is called on both the server and client. However, no data can be sent. No matter who sends the data (server or client), the receive_data function is never called. Prior to the update, this worked fine. Is there anything new I should know about with this part of backgroundrb? I didn''t see anything mentioned in the release announcement, but before I start digging deeper into the packet 1.9 code, I thought I would ask here first. Thanks in advance for any help! Daniel
On Sat, Jul 26, 2008 at 1:09 AM, Daniel Lockhart <daniel at newzwag.com> wrote:> I am a long time user of backgroundrb, and have used it''s server methods > (start_server and connect) to communicate data between various servers and > applications. It has been a great tool for this, and I feel fairly > comfortable with how the server and client communicate. > > With the latest version, however, I have encountered some problems. I can > successfully connect with ''connect'' to a server started with ''start_server'', > and the post_init function is called on both the server and client. > However, no data can be sent. No matter who sends the data (server or > client), the receive_data function is never called. Prior to the update, > this worked fine. Is there anything new I should know about with this part > of backgroundrb? I didn''t see anything mentioned in the release > announcement, but before I start digging deeper into the packet 1.9 code, I > thought I would ask here first. Thanks in advance for any help!Which OS?
Both servers are RHLE, one Red Hat 5, the other 4. The kernel on the 4 is 2.6.9-55.0.9.ELsmp which is 32 bit. The kernel on the 5 is 2.6.18-92.el5, which is 64 bit. Thanks again. On Jul 25, 2008, at 12:53 PM, hemant wrote:> On Sat, Jul 26, 2008 at 1:09 AM, Daniel Lockhart > <daniel at newzwag.com> wrote: >> I am a long time user of backgroundrb, and have used it''s server >> methods >> (start_server and connect) to communicate data between various >> servers and >> applications. It has been a great tool for this, and I feel fairly >> comfortable with how the server and client communicate. >> >> With the latest version, however, I have encountered some >> problems. I can >> successfully connect with ''connect'' to a server started with >> ''start_server'', >> and the post_init function is called on both the server and client. >> However, no data can be sent. No matter who sends the data (server >> or >> client), the receive_data function is never called. Prior to the >> update, >> this worked fine. Is there anything new I should know about with >> this part >> of backgroundrb? I didn''t see anything mentioned in the release >> announcement, but before I start digging deeper into the packet 1.9 >> code, I >> thought I would ask here first. Thanks in advance for any help! > > Which OS? >
On Sat, Jul 26, 2008 at 1:31 AM, Daniel Lockhart <daniel at newzwag.com> wrote:> Both servers are RHLE, one Red Hat 5, the other 4. The kernel on the 4 is > 2.6.9-55.0.9.ELsmp which is 32 bit. The kernel on the 5 is 2.6.18-92.el5, > which is 64 bit.Okay, I am assuming one of the workers is starting the server and perhaps other worker uses #connect to connect to the server started on previous worker, right? What might be happening is, when next worker attempts to connect, it may not find server up yet, hence you need to make reconnect attempt. This is of course, complete guess work, but for example: class Bar def receive_data p_data send_data(p_data) end def connection_completed puts "whoa man" end # will be automatically called when server refuses the connection, lets try to reconnect after 10 seconds # if reconnect fails unbind will be automatically called and next attempt will be made after 10 seconds. def unbind add_timer(10) { reconnect("localhost",2981,Bar) } end end class FooWorker < BackgrounDRb::MetaWorker set_worker_name :foo_worker def create(args = nil) # this method is called, when worker is loaded for the first time connect("localhost",2981,Bar) end end Also, there was a problem with add_timer.. when used within tcp connections like that, hence I had to release a new version of packet (0.1.10, its up on rubyforge.org). Let me know, if this fixes your problem.
Thanks again for your help. I discovered what the problem was; I had receive_data defined in a module that was included in the handler class. Apparently this was not getting called (I am guessing the way in which packet determines whether the method exists in the handler class changed, or the order in which modules are mixed in changed). Either way, moving the method directly into the handler class seems to have solved the problem. Thank you again for your help, I really love backgroundrb! Daniel On Jul 25, 2008, at 1:28 PM, hemant wrote:> On Sat, Jul 26, 2008 at 1:31 AM, Daniel Lockhart > <daniel at newzwag.com> wrote: >> Both servers are RHLE, one Red Hat 5, the other 4. The kernel on >> the 4 is >> 2.6.9-55.0.9.ELsmp which is 32 bit. The kernel on the 5 is >> 2.6.18-92.el5, >> which is 64 bit. > > Okay, I am assuming one of the workers is starting the server and > perhaps other worker uses #connect to connect to the server started on > previous worker, right? > > What might be happening is, when next worker attempts to connect, it > may not find server up yet, hence you need to make reconnect attempt. > This is of course, complete guess work, but for example: > > class Bar > def receive_data p_data > send_data(p_data) > end > > def connection_completed > puts "whoa man" > end > > # will be automatically called when server refuses the connection, > lets try to reconnect after 10 seconds > # if reconnect fails unbind will be automatically called and next > attempt will be made after 10 seconds. > def unbind > add_timer(10) { reconnect("localhost",2981,Bar) } > end > end > > class FooWorker < BackgrounDRb::MetaWorker > set_worker_name :foo_worker > def create(args = nil) > # this method is called, when worker is loaded for the first time > connect("localhost",2981,Bar) > end > end > > Also, there was a problem with add_timer.. when used within tcp > connections like that, hence I had to release a new version of packet > (0.1.10, its up on rubyforge.org). > > Let me know, if this fixes your problem. >