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…

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

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.

James Edward G. II

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

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.

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

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 G. II

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

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:incall2’
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:inmethodResponse’
/usr/local/lib/ruby/1.8/xmlrpc/create.rb:147:in collect' /usr/local/lib/ruby/1.8/xmlrpc/create.rb:147:inmethodResponse’
/usr/local/lib/ruby/1.8/xmlrpc/server.rb:378:in handle' /usr/local/lib/ruby/1.8/xmlrpc/server.rb:310:inprocess’
/usr/local/lib/ruby/1.8/xmlrpc/server.rb:760:in service' /usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:inservice’
/usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in run' /usr/local/lib/ruby/1.8/webrick/server.rb:173:instart_thread’
/usr/local/lib/ruby/1.8/webrick/server.rb:162:in start' /usr/local/lib/ruby/1.8/webrick/server.rb:162:instart_thread’
/usr/local/lib/ruby/1.8/webrick/server.rb:95:in start' /usr/local/lib/ruby/1.8/webrick/server.rb:92:ineach’
/usr/local/lib/ruby/1.8/webrick/server.rb:92:in start' /usr/local/lib/ruby/1.8/webrick/server.rb:23:instart’
/usr/local/lib/ruby/1.8/webrick/server.rb:82:in start' /usr/local/lib/ruby/1.8/xmlrpc/server.rb:648:inserve’
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 G. II

$ 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

thanks for trying…

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
fantasy-coders.de

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 G. II

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

    from /usr/local/lib/ruby/1.8/xmlrpc/client.rb:410:in `call'

methodResponse' /usr/local/lib/ruby/1.8/webrick/server.rb:95:instart’
eventually.
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 G. II

James G. 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…