james28909 has asked for the wisdom of the Perl Monks concerning the following question:
Howdy Monks! I am back again with another question. I am trying to establish a persistent connection to a gateway/websocket so i can add some functionality! I were trying to use REST::Client, but when the time come to do the connection/handshake with the actual gateway, i got something like "protocol not supported", which I took as REST::Client didnt support wss. I can connect to the api server all day long and read messages with REST::Client, but i cannot seems to post responses from my bot.
So this is where I started floundering around and copy/pasting code while not understanding it. Besides copy/pasting code, I believe IO::Socket would be a better approach to this, but I dont fully understand the whole server/client thing great either.
I would post some code but it would be the first failed attempt with the "protocol not supported" error.
To post code, I will post some psuedo code because I am not very sure as to what I need to do to actually make the request and read the responses with IO::Socket.
Do I need a server, or a client, or do I need a server and client? any help is very much appreciated :)
use strict; use warnings; use IO::Socket; use JSON; my $wss = 'ws://gateway'; my $client = IO::Socket->new($wss, 5000, tcp); #most examples use loca +lhost instead # do I do the handshake query here before the loop and then go to +the loop and start filtering # responses? while(1){ #filter responses }
I appreciate any hints of wisdom.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Persistent connection to a websocket/gateway (wss://)
by tobyink (Canon) on May 16, 2017 at 17:19 UTC | |
by james28909 (Deacon) on May 16, 2017 at 17:52 UTC | |
by james28909 (Deacon) on May 19, 2017 at 20:56 UTC | |
|
Re: Persistent connection to a websocket/gateway (wss://)
by RonW (Parson) on May 19, 2017 at 21:54 UTC | |
by james28909 (Deacon) on May 20, 2017 at 02:31 UTC |