Hi there,

Thanks for the answer.

My requirements aren't related with browsers... Imagine I've 50 clients
polling a server the ask if they need to "sync" themselves. I'm doing this
by making every client to do a request to the server asking if they need to
sync... this means that every 10 secs, 50 clients make a request asking the
same question... If the clientes are 500 instead of 50, you can imagine the
number of requests...

I was trying to use the websocket technology (or something similar) to
avoid all those requests... I find that having a Mojolicious websocket
server and a client (not browser) makes development less clear and more
complicated. Thats why I was looking for some sort of different approach
for this issue.

Thanks in advance.

On Tue, 19 May 2020 at 00:59, Felipe Gasper <fel...@felipegasper.com> wrote:

>
> > On May 18, 2020, at 7:45 PM, Miguel Manso <mma...@gmail.com> wrote:
> >
> > Hi there,
> >
> > Ive a Perl client that fetched some data every 3 seconds and post it to
> an API. Both client and server are written using mojo. Client uses
> Mojo::UserAgent to post JSON and server is a Mojolicious app being served
> with hypnotoad.
> >
> > I can have dozens of these clients which mean that each of them will be
> posting data and receiving from the server every 3 secs. I can easily do
> this using basic post calls but I wonder if there is a better way to
> achieve the same? Something like keeping connections opened for a period of
> time while sending and receiving data through the same connection?
> >
> > Ive seen websockets info but it seems it’s allways oriented to the
> client being in JavaScript.
> >
> > Any thoughts on the subject?
>
> We’ve had great success deploying WebSocket in lieu of TCP for
> server-to-server communication. You harness the routing that a web
> framework like Mojo does for you--so no futzing with firewalls and the
> like--but you still get the real-time communication that a raw TCP socket
> would give you. There’s a CLI utility called “websocat” that basically
> functions as “netcat for WebSocket”, if that’s of use to you.
>
> An alternative technology, if you only need a server-to-client stream, is
> Server-Sent Events (SSE). It’s basically an open-ended HTTP response, with
> the client parsing each chunk of that response as it arrives. Most browsers
> support it via the EventStream object, and I suspect it’d be pretty
> straightforward to rig up a Mojo SSE client, too. It’s a bit simpler, too,
> since it follows HTTP semantics. Not as robust, though, as it lacks the
> close status mechanism that WebSocket provides. (The server basically has
> to wait until it sees EPIPE/SIGPIPE to know that the client has stopped
> listening.)
>
> -FG
>
> --
> You received this message because you are subscribed to the Google Groups
> "Mojolicious" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mojolicious+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/mojolicious/B7BB55F8-9810-440B-9F79-919A1B664D05%40felipegasper.com
> .
>


-- 
Miguel Manso

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mojolicious/CAGdiW_8nhsgkuJfahxJB2gTfLqPJkHwpS5MGk_1PATTdn59DYw%40mail.gmail.com.

Reply via email to