First time poster. Learning Perl and have made good progress but I'm stumped by a problem I've encountered when attempting to implement WebSockets....

I have a WebSocket server application built in Node-Red sitting behind an Apache reverse-proxy configuration. (The server is very simple, responding only to 'Ping' commands with an 'OK' response.)

Using the 'Simple Websocket Client' extension for Google Chrome, I can successfully open the server URL, send the 'Ping' request and receive the 'OK' response, so I know that the server setup works.

However, attempting to implement the same in PERL via AnyEvent:Socket, I consistently receive a 'No such device or address' error.p>

The relevant section of my PERL code looks like this;

sub sockInit{ use AnyEvent::WebSocket::Client 0.12; use URI my $client = AnyEvent::WebSocket::Client->new( ); my $uri = URI->new('ws://mydomain.com/ws/test'); $client->connect($uri)->cb(sub { our $connection = eval { shift->recv }; if($@) { # handle error... myDebug($@); return; } # send a message through the websocket... # $connection->send('ping'); }); }

Ultimately, this fails in this section of AnyEvent/WebSocket/Client.pm (around line 90);

#AnyEvent::Socket::tcp_connect $uri->host, $uri->port, sub { AnyEvent::Socket::tcp_connect $uri->as_string, 80, sub { my $fh = shift; unless($fh) { $done->croak("unable to connect to ".$uri->as_string." $!"); return; }

(I've made some small edits there to get around issues with $uri->host and $uri->port not existing for URI::_generic which is what ws protocol comes through as. I've also extened the croak message to include the uri)

Here's what it typically generates;

unable to connect to ws://mydomain.com/ws/test No such device or addr +ess at /usr/share/squeezeboxserver/Plugins/Alexa/HabProxy.pm line 201 +.

(This code runs inside a plugin I'm writing for the Logitech SqueezeServer platform)

The relevant part of my Apache hosts config includes these libes in <VirtualHost *.80>

ProxyPass /ws ws://127.0.0.1:1880/ws ProxyPassReverse /ws ws://127.0.0.1:1880/ws

As noted, I know this to be working. Ultimately, I need this to work with user authentication in Apache against a DB and with WSS: but I've simplified extensively here to see if I can track down why my Perl implementation might be failing but it works fine in other clients.

I've learned a lot from this site so far, hopefully someone can help me out with my first problem for which my Google Fu cannot product an answer.


In reply to AnyEvent:WebSocket produces 'No such device or address' error by meep

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.