Starting XMLRPC server on virtual host returns EADDRNOTAVAIL

R

Rene Tschirley

Dear ruby experts,


I tried to start a Ruby XMLRPC server on a linux-based virtual host
(using OpenVZ).

Here is the code:

$server = {
"host" => "my.host.name",
"port" => 73726
}

XMLRPC::Server.new(port=$server['port'],host=$server['host'])

While the code works on a non-virtual host, bind returns EADDRNOTAVAIL
when the server is started on the virtual host:

[2006-12-05 11:35:24] INFO WEBrick 1.3.1
[2006-12-05 11:35:24] INFO ruby 1.8.5 (2006-08-25) [i486-linux]
[2006-12-05 11:35:24] WARN TCPServer Error: Cannot assign requested
address - bind(2)
/usr/lib/ruby/1.8/webrick/utils.rb:73:in `initialize': Cannot assign
requested address - bind(2) (Errno::EADDRNOTAVAIL)
from /usr/lib/ruby/1.8/webrick/utils.rb:73:in `new'
from /usr/lib/ruby/1.8/webrick/utils.rb:73:in `create_listeners'
from /usr/lib/ruby/1.8/webrick/utils.rb:70:in `each'
from /usr/lib/ruby/1.8/webrick/utils.rb:70:in `create_listeners'
from /usr/lib/ruby/1.8/webrick/server.rb:75:in `listen'
from /usr/lib/ruby/1.8/webrick/server.rb:63:in `initialize'
from /usr/lib/ruby/1.8/webrick/httpserver.rb:24:in `initialize'
from /usr/lib/ruby/1.8/xmlrpc/server.rb:635:in `new'
from /usr/lib/ruby/1.8/xmlrpc/server.rb:635:in `initialize'
from /net/usr/lib/libversand.rb:53:in `new'

I tried to define the host by giving the numeric address. I checked that
the host can resolve the hostname. The server can ping the server
address. The above code is started as superuser. Linux kernel version is
2.6.16, OpenVZ patch is version 026test015.

Any suggestions?


Thanks in advance,
Rene
 
R

Rene Tschirley

Caleb said:
Try a port number below 65536.

Sorry, I forgot to mention this: I tried to use other ports, too:
reserved ports below 1023, and ports between 1024 and 64k. This all
produces the same result (EADDRNOTAVAIL).

But anyway, thanks for your idea.


Rene
 
E

Eric Hodel

I tried to start a Ruby XMLRPC server on a linux-based virtual host
(using OpenVZ).

Here is the code:

$server = {
"host" => "my.host.name",
"port" => 73726
}

XMLRPC::Server.new(port=$server['port'],host=$server['host'])

While the code works on a non-virtual host, bind returns EADDRNOTAVAIL
when the server is started on the virtual host:

[2006-12-05 11:35:24] INFO WEBrick 1.3.1
[2006-12-05 11:35:24] INFO ruby 1.8.5 (2006-08-25) [i486-linux]
[2006-12-05 11:35:24] WARN TCPServer Error: Cannot assign requested
address - bind(2)
/usr/lib/ruby/1.8/webrick/utils.rb:73:in `initialize': Cannot assign
requested address - bind(2) (Errno::EADDRNOTAVAIL)

I tried to define the host by giving the numeric address. I checked
that
the host can resolve the hostname. The server can ping the server
address. The above code is started as superuser. Linux kernel
version is
2.6.16, OpenVZ patch is version 026test015.

For a WEBrick virtual host you need to pass :DoNotListen => true in
the configuration options for the vhost WEBrick::HTTPServer:

httpd = WEBrick::HTTPServer.new :DocumentRoot => nil
vhost = WEBrick::HTTPServer.new :DoNotListen => true,
:ServerName => 'vhost.example.com',
:DocumentRoot => nil
httpd.virtual_host vhost


I'm not sure how to do this with XMLRPC::Server, though.
 
R

Rene Tschirley

Michel Casabianca write:
Have you tried instantiating server with:

XMLRPC::Server.new(port=$server['port'])

Yes, I have tried this, too. Same result.

BTW: I forgot to mention the constructor's third parameter. In fact, I
call XMLRPC::Client.new(
$bestellungsServer['host'],
"/RPC2",
$bestellungsServer['port']
)


Rene
 
R

Rene Tschirley

Hi!


Eric said:
For a WEBrick virtual host you need to pass :DoNotListen => true in the
configuration options for the vhost WEBrick::HTTPServer:

I'm not very sure if I did get this right.

I did /not/ try to create a virtual XMLRPC server, analogue to a virtual
HTTP server which presents itself as HTTP server which runs adjacent to
an other server on the same host.

The virtual host which is ought to run the XMLRPC server is a virtual
root server with its own OS. This is realised by OpenVZ on OS-level. It
presents itself as a completely different machine.

Though I believe that the virtual host behaves /very/ similar to a
non-virtual host, the problem is obviously related to the server's
virtuality.

Anyway, defining DoNotListen didn't change anything. Thanks anyway!


Rene
 
R

Rene Tschirley

Hi all!


Thanks to you all who have meditated on my problem. I was able to solve
it and for documentation purposes, I now present the solution.

Problem:
I tried to start a Ruby XMLRPC server on a linux-based virtual host
(using OpenVZ). [...]
While the code works on a non-virtual host, bind returns EADDRNOTAVAIL
when the server is started on the virtual host:

[2006-12-05 11:35:24] INFO WEBrick 1.3.1
[2006-12-05 11:35:24] INFO ruby 1.8.5 (2006-08-25) [i486-linux]
[2006-12-05 11:35:24] WARN TCPServer Error: Cannot assign requested
address - bind(2)
/usr/lib/ruby/1.8/webrick/utils.rb:73:in `initialize': Cannot assign
requested address - bind(2) (Errno::EADDRNOTAVAIL)
from /usr/lib/ruby/1.8/webrick/utils.rb:73:in `new'
from /usr/lib/ruby/1.8/webrick/utils.rb:73:in `create_listeners'
from /usr/lib/ruby/1.8/webrick/utils.rb:70:in `each'
from /usr/lib/ruby/1.8/webrick/utils.rb:70:in `create_listeners'
from /usr/lib/ruby/1.8/webrick/server.rb:75:in `listen'
from /usr/lib/ruby/1.8/webrick/server.rb:63:in `initialize'
from /usr/lib/ruby/1.8/webrick/httpserver.rb:24:in `initialize'
from /usr/lib/ruby/1.8/xmlrpc/server.rb:635:in `new'
from /usr/lib/ruby/1.8/xmlrpc/server.rb:635:in `initialize'
from /net/usr/lib/libversand.rb:53:in `new'

I tried to define the host by giving the numeric address. I checked that
the host can resolve the hostname. The server can ping the server
address. The above code is started as superuser. Linux kernel version is
2.6.16, OpenVZ patch is version 026test015.

Solution:

The kernel routing table on a plain VE looks like this:

Destination Gateway Genmask Iface
191.255.255.1 * 255.255.255.255 venet0
default 191.255.255.1 0.0.0.0 venet0

The IP address 191.255.255.1 seems to be a OpenVZ-related special IP
address which is used to route the client's IP traffic to the host.

I changed these routes to match the intranet's common values:

Destination Gateway Genmask Iface
192.168.1.0 * 255.255.255.0 venet0
default 192.168.1.0 0.0.0.0 venet0

Now, the XMLRPC server is able to open the port. Somehow, the server
wasn't able to open the port with the other routing tables. Note that
the interface venet0 was correctly set to listen to IP address
192.168.1.n in both cases!


Rene
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top