rjray / rpc-xml

A Perl implementation of the XML-RPC specification
https://metacpan.org/release/RPC-XML
24 stars 14 forks source link

Accessing the server from multiple addresses #1

Closed carcus88 closed 14 years ago

carcus88 commented 14 years ago

I've tried just about everything I can think of but I cannot seem to make the server respond on multiple addresses.

For example if I create a server

my $srv = RPC::XML::Server->new(port => 8082, timeout => 120, url => '/RPC2');

Assume that we are using a local address 192.168.1.10

And try to access the server at http://127.0.0.1:8082/RPC2 it works fine BUT when I try http://localhost:8082/RPC2
or
http://192.168.1.10:8082/RPC2

It does not respond. Now if I try http://localhost:8082/RPC2 first then then other two addresses don't work. It seems that whatever address I try first becomes the only address that I can hit the server on until I restart it.

So it seems that its binded to all addresses but it can only respond on one and its always the first address that is used by a client connection.

rjray commented 14 years ago

I've tried to replicate this, but when I do it it works fine for me. First, in one terminal window I do this:

% perl -MRPC::XML::Server -e 'RPC::XML::Server->new(port => 10001)->server_loop'

Then, in a second window I do a HEAD request against the server (my server class by default accepts HEAD requests and returns basic header data):

{ gangrel: 532 } HEAD http://192.168.1.6:10001 200 OK Connection: close Date: Wed, 04 Aug 2010 03:51:30 GMT Accept: text/xml Accept-Encoding: deflate Server: libwww-perl-daemon/5.827 Content-Type: text/xml Client-Date: Wed, 04 Aug 2010 03:51:30 GMT Client-Peer: 192.168.1.6:10001 Client-Response-Num: 1 RPC-Encoding: XML-RPC RPC-Server: RPC::XML::Server/1.56

{ gangrel: 533 } HEAD http://127.0.0.1:10001 200 OK Connection: close Date: Wed, 04 Aug 2010 03:51:33 GMT Accept: text/xml Accept-Encoding: deflate Server: libwww-perl-daemon/5.827 Content-Type: text/xml Client-Date: Wed, 04 Aug 2010 03:51:33 GMT Client-Peer: 127.0.0.1:10001 Client-Response-Num: 1 RPC-Encoding: XML-RPC RPC-Server: RPC::XML::Server/1.56

{ gangrel: 534 } HEAD http://localhost:10001 200 OK Connection: close Date: Wed, 04 Aug 2010 03:51:41 GMT Accept: text/xml Accept-Encoding: deflate Server: libwww-perl-daemon/5.827 Content-Type: text/xml Client-Date: Wed, 04 Aug 2010 03:51:41 GMT Client-Peer: 127.0.0.1:10001 Client-Response-Num: 1 RPC-Encoding: XML-RPC RPC-Server: RPC::XML::Server/1.56

carcus88 commented 14 years ago

Sorry about the false bug but I forgot to update with what I later found was the issue. I am using the ActiveState perlsvc to package the application and it will produce this behavior unless you explicitly load RPC::XML::Parser::XMLParser

If I compile my app this way I will get the strange behavior

package ssXMLRPCServer; use RPC::XML; use RPC::XML::Server; use UUID::Tiny; use Carp;

But If I do this the problem goes away

package ssXMLRPCServer; use RPC::XML; use RPC::XML::Server; use RPC::XML::Parser::XMLParser; # Must be explicity loaded for executable to pack correctly use UUID::Tiny; use Carp;

Seems that when running from a non packaged app it can find and load RPC::XML::Parser::XMLParser on the fly but when packaged if this is not explicity included it will fail. I guess this would not be a bug but more a use case. Might be helpfull to have in the pitfalls sections of the docs though if anyone else is using RPC::XML::Server to make windows services.

Thanks