develooper Front page | perl.beginners | Postings from April 2020

Re: IO::Socket::Multicast::mcast_send

Thread Previous
From:
James Kerwin
Date:
April 5, 2020 16:22
Subject:
Re: IO::Socket::Multicast::mcast_send
Message ID:
CAKkNZ9D75LDkDxLYQGzMjs1wOZak+s_ajqc12vr4R6M+fUZ0sw@mail.gmail.com
Hi thanks for the response.

Before I continue, at the top of the script I first borrowed for this it
had "use 5.026;". When I remove this and then alter any "say" or "break"
etc that appear the scripts continue to work as before; Mint laptop works,
Pi does not.

1) For PI:
Pi Raspbian GNU/Linux 10 (buster).
Perl Version: v5.28.1 (installed with OS).

ufw is not installed. I don't THINK any other firewalls are installed. I
haven't installed any and I don't think there's one by default. This was a
fresh install of Rasbpian done just this week.

Looking at iptables:
$ sudo iptables -L -nv
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source
destination

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source
destination

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source
destination

For Linux:
Linux Mint 18 (Sarah)
Perl: v5.26.0 (switched using perlbrew if memory serves me correctly. Some
modules wouldn't install due to the Perl version that came with the OS).

ufw is disabled. When I activate it the script does not work, but it
doesn't give an error pointing at the line where $socket->mcast_send is
called, as it does on the pi.

iptables gives a massive output.

2) I have not tried it with the latest stable version of Perl, partly
because I have several different versions of Perl where it does/doesn't
work and I'd mentally ruled out the Perl version. For example it doesn't
work with the Perl on my Windows laptop, but doesn't give an error so my
suspicion there is it's something firewall related.

3) I will check out those links. I've just quickly looked through the
script on the laptop with the debugger. I'll go check with the pi when I
can get back on it (plugged in to TV, Tv in use).

4) Mentioned this in 1.

I'll keep at it for now, and keep trying things. I am able to identify the
bulb when I log into the router and can directly ping the ip from the
laptop and pi.

Thanks,
James

On Sun, Apr 5, 2020 at 4:03 PM Shlomi Fish <shlomif@shlomifish.org> wrote:

> Hi James,
>
> On Sun, 5 Apr 2020 14:58:26 +0100
> James Kerwin <jkerwin2101@gmail.com> wrote:
>
> > Hi All,
> >
> > I'm trying to connect to a smart bulb on my home WIFI using mcast_send
> > in IO::Socket::Multicast.
> >
> > It works on my main Linux Mint laptop. The same script does not work on
> my
> > Raspberry PI.
> >
> > Despite the script running as expected on one laptop I've checked that
> this
> > is all set up correctly:
> >
> > sub new {
> >     #my $class = shift;
> >     my $data  = {
> >         address => '239.255.255.250',
> >         port    => 1982,
> >         timeout => 3,
> >         devices => [],
> >     };
> >     return bless( $data );
> > }
> >
>
> It is a good idea to use bless with an explicit package name or just use
> https://metacpan.org/pod/Moo or Moose or similar.
>
> > my $socket = IO::Socket::Multicast->new(
> >         PeerAddr  => $self->{address},
> >         PeerPort  => $self->{port},
> >         Proto     => "udp",
> >         ReuseAddr => 1,
> >     ) or croak $!;
> >
> > But it's this part that fails on the PI:
> >
>
> A few things to check:
>
> 1. Which OS/distro/version and perl version  on both machines?
>
> 2. Does it happen with the latest stable perl installed from source?
>
> 3. Did you try using https://en.wikipedia.org/wiki/GDB and/or perl -d:
> https://perl-begin.org/topics/debugging/ ?
>
> 4. Is there anything in the rpi's firewall config?
>
> For more advice, see
> https://github.com/shlomif/writing-the-perfect-question .
>
> > $socket->mcast_send( $query, "$self->{address}:$self->{port}" ) or croak
> $!;
> >
> > I've checked that $socket, $query and $self->{address}:$self->{port}
> > contain the info I expect and they do.
> >
> > On my Linux laptop I can use tcpdump and see the communication between
> > laptop and bulb. Doing this on the Pi shows no communication. I've
> replaced
> > the "croak" with "die "zzzzzzzzzzzz" so I can be certain it's failing at
> > that point. I get the output "zzzzzzzzzzzz" (makes it easier to spot).
> >
> > I've just used a command recently that allows me to access the specific
> ip
> > and port of the lamp and it indicates the connection is successful. I'm
> out
> > of ideas and if anyone can advise I'd appreciate it.
> >
> > Slightly (very) out of my depth when it comes to ports and IPs etc.
> >
> > Thanks,
> > James
>
>
>
> --
>
> Shlomi Fish       https://www.shlomifish.org/
> https://github.com/shlomif/validate-your-html - Validate Your HTML
>

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About