Accessing RPC server using perl



I’m having problems to access the RPC server using Perl. I’m not sure if the problem is a my side, or on the RPC server side.

I’m running a Raspberry Pi with Wheezy, homegear version 0.3.1-2 (see

I wrote a very little test program in Perl which simply calls method “listDevices”. I run the program on a Windows PC which connects to my Raspberry Pi on Port 2001. The following error is reported:

[color=#BF0000]Unknown value for HTTP header “Connection”: TE, close Buffer: POST / HTTP/1.1[/color]

This is the full log from “homegear.err”, showing all HTTP header fields:

02/16/14 11:18:46.303 XML RPC Server: Could not process HTTP packet: Unknown value for HTTP header "Connection": TE, close Buffer: POST / HTTP/1.1
TE: deflate,gzip;q=0.3
Connection: TE, close
User-Agent: libwww-perl/6.05
Content-Type: text/xml
Content-Length: 105

<?xml version="1.0"?>

To exclude other error reasons, I tried two different XMP-RPC Perl implementations (modules): “XML::RPC” and “Frontier::Client”, but either module produces the same error log. I am not too good in programming Perl (I’m still about learning Perl), but I guess since the example task is fairly simple there is not much I could do wrong - I just adapted example programs which I found for XMP-RPC-Clients.

So the first thing to analyze is: Is this a client side problem (my problem), or ist it a server side problem (Homegear problem)? For me it looks as if the RPC server not capable of handling requests coming form Perl modules. The error log states some unexpected HTTP header fields, regardless which RPC clinet implementation I use. I looked up the “TE” field in the HTTP specification, it seems to be correct usage of HTTP.

Any hints?


PS: I notice the documentation on your website is growing. Thanks! Good work, keep going on!


Hey Klaus,

the value “TE” was not supported for the header field “connection”. So it was a problem with Homegear. I added it now and version 0.3.2 is compiling. I should be able to upload it in about 2 hours. Please tell me, if it is working with the new version :wink:.



Hi Sathya,

yep, version 0.3.2 works. Thanks for your quick response.



Great :smiley:. If you have any further problems, don’t hesitate to ask.


Hi Sathya,

now I’m getting error code -32700 on client side from the perl XML RPC stack, with this error text: Parse error. First root node has to be “methodCall”.

I cannot see the XML which was sent to the server, but I guess it’s the same as in my first post, and the root node appearently is “methodCall”. Any ideas?

I increased debugLevel in main.conf (up to 99 :slight_smile:, hoping to see the XML which was transmitted, but the XML text was not shown. Maybe it would be helpful to dump XML data into the log file at a certain log level?

// Klaus


Hey Klaus,

when you set debug level to 5 (that’s enough), the response get’s logged in hexadecimal format (the reason is, it takes time to convert it back to string). There should be something like "Response binary: " in the log file. You can use online tools like to convert it to string.
When you attach your example perl program, I can quickly check, what’s wrong.



I changed the debug output to string now in the master branch. You are right, it’s much easier for debugging :wink:.


I was aware about the hex code in the log file, but was too lazy to convert it by myself and too stupid to look for an online converter :blush:. Thanks for the link to the online hex-to-string converter. Hex code in log file is ok for me. Here is what was logged:

Packet received:

Translates to:

[code]POST / HTTP/1.1
TE: deflate,gzip;q=0.3
Connection: TE, close
User-Agent: XML-RPC/0.9
Content-Length: 122
Content-Type: text/xml

<?xml version="1.0" encoding="UTF-8" ?> listDevices [/code]

This looks good to me. Still want to have a look at my Perl example script?

And this is what was logged as response packet:

[code]HTTP/1.1 200 OK
Connection: close
Content-Type: text/xml
Content-Length: 288

<?xml version="1.0"?>faultCode-32700faultStringParse error. First root node has to be "methodCall".[/code]

// Klaus


For some reason the XML parser I use is not able to parse the request. The request looks good to me, too. The Perl script would be nice :wink:.


I cannot upload the script in the forum (“Die Dateierweiterung pl ist nicht erlaubt.”). Here it is inline:

[code]#! /usr/bin/perl

© Copyright 2014 Klaus Rogall


Programm zum Testen des Homegear-BidCos-RPC-Servers.


use strict;
use warnings;
use XML::RPC;
use Frontier::Client;

p(“BidCos RPC Test”);

my $rpcHost = “”;
my $rpcPort = “2001”;
my $rpcPath = “/”;

my $rpcURL = “http://” . $rpcHost . “:” . $rpcPort . $rpcPath;

p("Connecting to " . $rpcURL . “…”);
my $xmlrpc = XML::RPC->new($rpcURL);
#my $xmlrpc = Frontier::Client->new(url => $rpcURL);

p(“Sending remote procedure call”);
my $result = $xmlrpc->call(“listDevices”);
my %values = %$result;

for (keys %values)
my $key = $_;
p("- " . $key . ": " . $values{$key});


Gibt eine Meldung in die Standardausgabe aus.

Jede Zeile wird mit einem Zeilenvorschub abgeschlossen.


0: Die Meldung. Der Default-Wert ist der Leerstring.


sub p
my $message = shift || “”;

print($message . "\n");


For easier testing I run this example on WIndows using “Strawberry Perl”. The code uses module “XML::RPC”. I get the same result with “Frontier::Client” which is also an RPC library - (un)comment line 26 and 27. So it’s not a matter of the XML RPC library.

// Klaus


BTW: I did not yet pair a device with my CUL, but that should not affect XML parsing…


Here your script works perfectly with Frontier::Client and XML::RPC :cry:. I have no idea what is going on. I checked it with version 0.4.0 though. I’m just downloading the Raspberry Pi image with version 0.3.2 and will check it again.
No, that no device is paired shouldn’t effect the RPC server.


Could you check, if you get a response with PHP ( and


Yes sure I will do that - but I have to stop for today. I plan to continue the issue tomorrow evening after work. Thanks so far for your assistance.

// Klaus


ok, I found the error. When I added support for “TE” in the HTTP connection header field, I did that in the master branch and then copied the changes to the “0.3” branch - but not all of them. Stupid… I’m sorry…


Version 0.3.2-2 is compiling and should be online in two hours. I’m waiting for your feedback :wink:.


Just downloaded the latest package. Version 0.3.2-2 works as expected. Thank’s a lot!!! :mrgreen:

// Klaus


Glad to hear it :smiley:.