Most viable WebSocket/Perl solution
Asked Answered
B

2

7

The company I'm working at uses Perl for all "backend related" stuff. However, we would like to use some real-time communication between server-processes and connected clients via browser.

We are also using Apache as Webserver with mod.perl. So that is my first question, I don't see any practical way to combine a WebSocket-Server in that constelation. Maybe there is one I didn't found yet?

The only thing which really works serious about that topic, is Mojolicious. However I'm not that experienced with that yet, so I'd be happy if someone could state if I can use that in my current mod-perl environment. I think I also would have to let this run as standalone webserver process, No?

Which brings me to my second question. What is the best practice, if you have multiple perl files, which do certain things running on Apache/modperl, but you want to keep all your connected users informed about things. What I mean is, all these scripts are accessed via XHR, but some actions require other users to get informed. Currently, we do a classic ajax polling.

The problem I'm struggling around with is, that if there is a dedicated websocket server, which runs independently, all those scripts would need to somehow communicate with this process as well right ? How would one do that? Pipes? Sockets? Shared memory ?

Theoretically, if I would choose to go with such an independent ws server solution, I could write it in any language right? Could even be Ruby or Node. I'm just wondering if that is the best way or if there is a good solution which is more integrated in existing perl/modperl constructs.

TL;DR
Is it best practice to have a standalone, independent web-socket server which communicates with the rest of your Apache/modperl scripts aswell as with its connected clients ?

Bouley answered 27/11, 2012 at 9:59 Comment(0)
F
1

You could look on AnyEvent CPAN module: http://metacpan.org/pod/AnyEvent

With it you can write your own standalone event-driven WebSocket-server, also you could find a lot of examples in google or in AnyEvent's perldoc.

Frilling answered 27/11, 2012 at 17:9 Comment(0)
W
0

Since the OP question in 2012, there is now the perl module WebSocket on CPAN, which is easy to use and versatile.

If you use Apache, you may want to use reverse proxy like:

ProxyRequests Off
ProxyPass /wss            ws://localhost:8080
ProxyPassReverse /wss     ws://localhost:8080

And have a perl script use WebSocket::Server

Wolfort answered 19/10, 2023 at 3:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.