Xmlrpc problems

Hi @all

I would like to call a method asynchron on a other pc with xmlrpc
1.7.16!
For the background: I've 2 computers (sender / receiver) in my network
and I would like to sniff the networktraffic from sender to receiver on
the receiver (with the pcap-library). So I call the method
start_sniffing() on the receiver asynchron and start with sending on the
sender. But it didn't run!
To establish the connection, it during over 20 sec, but the network run
correctly.

Does anyone know a solution or have the same problem? thanks for
helping...

···

--
Posted via http://www.ruby-forum.com/.

Could you possibly show a simple server and client script that don't work for you? It would probably be easier for us to help if we saw that.

James Edward Gray II

···

On Nov 15, 2007, at 9:58 AM, K. R. wrote:

I would like to call a method asynchron on a other pc with xmlrpc
1.7.16!
For the background: I've 2 computers (sender / receiver) in my network
and I would like to sniff the networktraffic from sender to receiver on
the receiver (with the pcap-library). So I call the method
start_sniffing() on the receiver asynchron and start with sending on the
sender. But it didn't run!
To establish the connection, it during over 20 sec, but the network run
correctly.

Does anyone know a solution or have the same problem? thanks for
helping...

Could you possibly show a simple server and client script that don't
work for you? It would probably be easier for us to help if we saw
that.

sorry, here is my sourcecode. I hide the code for sending and sniffing
network traffic, because it isn't important for my connecting problem.
Thanks for your help !!!

Sender:

···

-------
require 'xmlrpc/client'
server = XMLRPC::Client.new(destAdd,"/RPC2",20000)

server.call("sniffing.connect", 25000, "192.168.10.10")
Thread.new {
  server.call_async("sniffing.start")
}
# Now sending network traffic
# ...
server.call("sniffing.stop")

Receiver:
---------
require 'xmlrpc/server'

class Sniffer
  def initialize(port, ip)
    @port = port
    @ip = ip
  end

  def start
    # Use the pcap library to sniff at port @port from ip @ip
    # ...
  end

  def stop
    # Stop the sniffer
    # ...
  end
end

s = XMLRPC::Server.new(20000, "192.168.10.2")
s.add_handler("sniffing.connect") do |port, ip|
  sniffer = Sniffer.new(port, ip)
end

s.add_handler("sniffing.start") do
  sniffer.start
end

s.add_handler("sniffing.stop") do
  sniffer.stop
end
s.serve
--
Posted via http://www.ruby-forum.com/\.

Could you possibly show a simple server and client script that don't
work for you? It would probably be easier for us to help if we saw
that.

sorry, here is my sourcecode.

I wasn't able to run this code…

server = XMLRPC::Client.new(destAdd,"/RPC2",20000)

The variable in this line isn't defined, but I switched it to my server address.

server.call("sniffing.connect", 25000, "192.168.10.10")

I don't see this method in the server. The script errors out at this point.

James Edward Gray II

···

On Nov 15, 2007, at 1:50 PM, K. R. wrote:

I wasn't able to run this code�

server = XMLRPC::Client.new(destAdd,"/RPC2",20000)

The variable in this line isn't defined, but I switched it to my
server address.

Of course, because your network can be designed in an other ip
structure.

server.call("sniffing.connect", 25000, "192.168.10.10")

I don't see this method in the server. The script errors out at this
point.

This method call the handler "sniffing.connect" at the server. The
handler is registered just below of s = XMLRPC::Server.new(20000,
"192.168.10.2"), so I didn't see the problem. In method start of class
sniffer, I actually use a while loop until the sender stop the
sendingstream.

···

--
Posted via http://www.ruby-forum.com/\.

server.call("sniffing.connect", 25000, "192.168.10.10")

I don't see this method in the server. The script errors out at this
point.

This method call the handler "sniffing.connect" at the server. The
handler is registered just below of s = XMLRPC::Server.new(20000,
"192.168.10.2"), so I didn't see the problem.

You are exactly right, of course. I'm sorry. I didn't pay enough attention when I was fiddling with this problem earlier.

In method start of class sniffer, I actually use a while loop until the sender stop the sendingstream.

I have sat over here fiddling with this thing half the night and I can't seem to get that far. When I run your server and client I get a type error for the arguments. I see this on error the client:

/usr/local/lib/ruby/1.8/xmlrpc/client.rb:546:in `do_rpc': HTTP-Error: 500 Internal Server Error (RuntimeError)
         from /usr/local/lib/ruby/1.8/xmlrpc/client.rb:420:in `call2'
         from /usr/local/lib/ruby/1.8/xmlrpc/client.rb:410:in `call'
         from client.rb:6

And the server reports:

[2007-11-15 21:15:20] ERROR RuntimeError: Wrong type!
         /usr/local/lib/ruby/1.8/xmlrpc/create.rb:274:in `conv2value'
         /usr/local/lib/ruby/1.8/xmlrpc/create.rb:148:in `methodResponse'
         /usr/local/lib/ruby/1.8/xmlrpc/create.rb:147:in `collect'
         /usr/local/lib/ruby/1.8/xmlrpc/create.rb:147:in `methodResponse'
         /usr/local/lib/ruby/1.8/xmlrpc/server.rb:378:in `handle'
         /usr/local/lib/ruby/1.8/xmlrpc/server.rb:310:in `process'
         /usr/local/lib/ruby/1.8/xmlrpc/server.rb:760:in `service'
         /usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
         /usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
         /usr/local/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
         /usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start'
         /usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
         /usr/local/lib/ruby/1.8/webrick/server.rb:95:in `start'
         /usr/local/lib/ruby/1.8/webrick/server.rb:92:in `each'
         /usr/local/lib/ruby/1.8/webrick/server.rb:92:in `start'
         /usr/local/lib/ruby/1.8/webrick/server.rb:23:in `start'
         /usr/local/lib/ruby/1.8/webrick/server.rb:82:in `start'
         /usr/local/lib/ruby/1.8/xmlrpc/server.rb:648:in `serve'
         server.rb:37
localhost - - [15/Nov/2007:21:15:20 CST] "POST /RPC2 HTTP/1.1" 500 292
- -> /RPC2

I haven't figured this out yet, but I'm still trying. I'll get it eventually.

Can I ask what version of Ruby you are using? Mine is:

$ ruby -v
ruby 1.8.6 (2007-09-23 patchlevel 110) [i686-darwin8.10.1]

James Edward Gray II

···

On Nov 15, 2007, at 5:00 PM, K. R. wrote:

$ ruby -v
ruby 1.8.6 (2007-09-23 patchlevel 110) [i686-darwin8.10.1]

I use the same ruby version as you. Examples and usable how to's are on
http://www.fantasy-coders.de/ruby/xmlrpc4r/howto.html

thanks for trying...

···

--
Posted via http://www.ruby-forum.com/\.

I now understand this error and why I was getting it. Your handler for "sniffer.connect" returns a Sniffer object, which is not a legal return value for XML-RPC. You could use a combination of Config::ENABLE_MARSHALLING and XMLRPC::Marshallable to get Ruby's implementation to dump it, but that doesn't seem to be what you wanted here.

I added a simple:

   true

to the end of all of your handlers and then the server and client ran for me.

Here are the total changes I made. First, the server:

#!/usr/bin/env ruby -wKU

require 'xmlrpc/server'

class Sniffer
   def initialize(port, ip)
     @port = port
     @ip = ip
   end

   def start
     # Use the pcap library to sniff at port @port from ip @ip
     # ...
     puts "Started sniffing..."
   end

   def stop
     # Stop the sniffer
     # ...
     puts "Stopped sniffing..."
   end
end

s = XMLRPC::Server.new(8080)
sniffer = nil

s.add_handler("sniffing.connect") do |port, ip|
   sniffer = Sniffer.new(port, ip)
   true
end
s.add_handler("sniffing.start") do
   sniffer.start if sniffer
   true
end
s.add_handler("sniffing.stop") do
   sniffer.stop if sniffer
   true
end

s.serve

__END__

And here is my client:

#!/usr/bin/env ruby -wKU

require 'xmlrpc/client'
server = XMLRPC::Client.new("localhost", "/RPC2", 8080)

server.call("sniffing.connect", 25000, "192.168.10.10")

Thread.new {
   server.call_async("sniffing.start")
}
# Now sending network traffic
# ...
sleep 2

server.call("sniffing.stop")

__END__

Will these scripts run for you now, as is?

James Edward Gray II

···

On Nov 15, 2007, at 9:22 PM, James Edward Gray II wrote:

In method start of class sniffer, I actually use a while loop until the sender stop the sendingstream.

I have sat over here fiddling with this thing half the night and I can't seem to get that far. When I run your server and client I get a type error for the arguments. I see this on error the client:

/usr/local/lib/ruby/1.8/xmlrpc/client.rb:546:in `do_rpc': HTTP-Error: 500 Internal Server Error (RuntimeError)
        from /usr/local/lib/ruby/1.8/xmlrpc/client.rb:420:in `call2'
        from /usr/local/lib/ruby/1.8/xmlrpc/client.rb:410:in `call'
        from client.rb:6

And the server reports:

[2007-11-15 21:15:20] ERROR RuntimeError: Wrong type!
        /usr/local/lib/ruby/1.8/xmlrpc/create.rb:274:in `conv2value'
        /usr/local/lib/ruby/1.8/xmlrpc/create.rb:148:in `methodResponse'
        /usr/local/lib/ruby/1.8/xmlrpc/create.rb:147:in `collect'
        /usr/local/lib/ruby/1.8/xmlrpc/create.rb:147:in `methodResponse'
        /usr/local/lib/ruby/1.8/xmlrpc/server.rb:378:in `handle'
        /usr/local/lib/ruby/1.8/xmlrpc/server.rb:310:in `process'
        /usr/local/lib/ruby/1.8/xmlrpc/server.rb:760:in `service'
        /usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
        /usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
        /usr/local/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
        /usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start'
        /usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
        /usr/local/lib/ruby/1.8/webrick/server.rb:95:in `start'
        /usr/local/lib/ruby/1.8/webrick/server.rb:92:in `each'
        /usr/local/lib/ruby/1.8/webrick/server.rb:92:in `start'
        /usr/local/lib/ruby/1.8/webrick/server.rb:23:in `start'
        /usr/local/lib/ruby/1.8/webrick/server.rb:82:in `start'
        /usr/local/lib/ruby/1.8/xmlrpc/server.rb:648:in `serve'
        server.rb:37
localhost - - [15/Nov/2007:21:15:20 CST] "POST /RPC2 HTTP/1.1" 500 292
- -> /RPC2

I haven't figured this out yet, but I'm still trying. I'll get it eventually.

Did you follow the download link at that page to get XML-RPC or are you using the standard library that ships with Ruby?

A not-really-related question: can you control-C your server? Mine captures and ignores the interrupt.

James Edward Gray II

···

On Nov 16, 2007, at 1:33 AM, K. R. wrote:

$ ruby -v
ruby 1.8.6 (2007-09-23 patchlevel 110) [i686-darwin8.10.1]

I use the same ruby version as you. Examples and usable how to's are on
http://www.fantasy-coders.de/ruby/xmlrpc4r/howto.html

James Gray wrote:

I now understand this error and why I was getting it. Your handler
for "sniffer.connect" returns a Sniffer object, which is not a legal
return value for XML-RPC.

Wow, thanks for your help!!!!! This mistake was the point of failure.
Great! Thanks...

···

--
Posted via http://www.ruby-forum.com/\.