OpenSprinkler Forums OpenSprinkler Unified Firmware OpenSpinkler server sends back RST using HTTP::Tiny

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #39020

    jdent
    Participant

    Using OpenSprinkler Pi, App 1.4.5, firmware 2.1.5(1)

    I’m trying to make API calls using Perl running on my pi and HTTP::Tiny (included in Raspbian). 9+ times out of 10, when I run the program, the GET request returns:

    Could not read from socket: ‘Connection reset by peer’ at /usr/share/perl/5.14/HTTP/Tiny.pm line 162

    Doing a packet trace, I see that OpenSprinkler is sending the response data back, but instead of closing the connection normally, it sends back an RST. Curl for the exact same URL always works and I see the connection being properly closed. The test program is very simple, so hopefully the problem can be easily duplicated:

    #!/usr/bin/perl
    
    use JSON::PP;
    use HTTP::Tiny;
    use strict;
    require "dumpvar.pl";
    
    my ($response, $decodedResult, $json, $url, $http);
    
    $url = 'http://127.0.0.1:8080/jc?pw=hashedpasswordhere';
    $http = HTTP::Tiny->new(
                    'proxy' => undef,
                     );
    $response = $http->get($url);
    
    dumpValue ($response);
    
    if (!$response->{success}) {
            print STDERR "Request failed: " . $response->{content} . "\n";
            exit 1;
            }
    
    $json = JSON::PP->new->ascii->pretty->allow_nonref;
    $decodedResult = $json->decode( $response->{content} );
    
    dumpValue ($decodedResult);
    
Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.

OpenSprinkler Forums OpenSprinkler Unified Firmware OpenSpinkler server sends back RST using HTTP::Tiny