erland
2010-05-18, 23:04
I get the following error from SimpleAsyncHTTP when I try to download an icon from my MythTV box.
==============
Error reading headers: Server closed connection without sending any data back at /media/disk2/squeezecenter/7.5/server/CPAN/Net/HTTP/Methods.pm line 306.
...propagated at /media/disk2/squeezecenter/7.5/server/CPAN/Net/HTTP/NB.pm line 32.
=============
I'm calling it like this:
my $iconurl = 'http://172.16.0.114:6544/Myth/GetChannelIcon?ChanId=2307';
my $iconid = '2307';
my $cachedir = $serverPrefs->get('cachedir');
my $icondir = catdir( $cachedir, 'MythTVIcons' );
my $iconpath = catfile( $icondir, $iconid );
my $http = Slim::Networking::SimpleAsyncHTTP->new(
sub {},
sub {
my $http = shift;
my $error = $http->error;
$log->error( "$error" );
},
{
saveAs => $iconpath,
iconurl => $iconurl,
iconid => $iconid,
},
);
my %headers;
if ( -e $iconpath ) {
$headers{'If-Modified-Since'} = time2str( (stat $iconpath)[9] );
}
$http->get( $iconurl, %headers );
The strange thing is that it works sometimes and sometimes not.
Have I missed something obvious ?
If you want to see the code in the full context, it's available here:
http://erlandplugins.googlecode.com/svn/MythTV/trunk/src/Plugin.pm
(Look for the "cacheIcon" function)
I don't think I saw these kind of messages earlier with an earlier 7.x release, it was probably during 7.4 beta when I run this code last.
Note, this might all be caused by something on the MythTV side, but it seems to work perfectly all the time when I access the same URL from a web browser.
==============
Error reading headers: Server closed connection without sending any data back at /media/disk2/squeezecenter/7.5/server/CPAN/Net/HTTP/Methods.pm line 306.
...propagated at /media/disk2/squeezecenter/7.5/server/CPAN/Net/HTTP/NB.pm line 32.
=============
I'm calling it like this:
my $iconurl = 'http://172.16.0.114:6544/Myth/GetChannelIcon?ChanId=2307';
my $iconid = '2307';
my $cachedir = $serverPrefs->get('cachedir');
my $icondir = catdir( $cachedir, 'MythTVIcons' );
my $iconpath = catfile( $icondir, $iconid );
my $http = Slim::Networking::SimpleAsyncHTTP->new(
sub {},
sub {
my $http = shift;
my $error = $http->error;
$log->error( "$error" );
},
{
saveAs => $iconpath,
iconurl => $iconurl,
iconid => $iconid,
},
);
my %headers;
if ( -e $iconpath ) {
$headers{'If-Modified-Since'} = time2str( (stat $iconpath)[9] );
}
$http->get( $iconurl, %headers );
The strange thing is that it works sometimes and sometimes not.
Have I missed something obvious ?
If you want to see the code in the full context, it's available here:
http://erlandplugins.googlecode.com/svn/MythTV/trunk/src/Plugin.pm
(Look for the "cacheIcon" function)
I don't think I saw these kind of messages earlier with an earlier 7.x release, it was probably during 7.4 beta when I run this code last.
Note, this might all be caused by something on the MythTV side, but it seems to work perfectly all the time when I access the same URL from a web browser.