Hi,

I am trying to write a simple Perl code which subscribe messages from ZeroMQ 
and publish them over WebSocket using Mojolicious.
As soon as I subscribe to zeromq for receiving messages, the websocket sent 
part stops working.
If I try to dump the $self->tx, I see the messages and the correct client 
information, but no data is being sent.

Please find below a sample code snippet for this,

#!/usr/bin/perl

use strict;
use warnings;
use Data::Dumper;
use Mojolicious::Lite;
use ZMQ::LibZMQ3;
use ZMQ::Constants qw(:all);

websocket '/paper' => sub {
                my $self = shift;

                my $ctxt = zmq_init;
                my $socket = zmq_socket( $ctxt, ZMQ_SUB );
                zmq_connect( $socket, "tcp://manu.rsi.com:7000" );

                $self->app->log->debug('WebSocket connected.');

                $self->send('WebSocket connected.');

                zmq_setsockopt($socket,ZMQ_SUBSCRIBE,ZMQ_NOBLOCK);
                while(my $msg = zmq_recvmsg( $socket )){
                                $self->send("Received a message data");
                }

                zmq_close($socket);

};

app->start;


Please let me know if I am missing something or is there a different way to 
achieve this.
I am trying a simple glue code, which gets Messages over ZeroMQ and send over 
Mojo WebSocket.

Thanks
Manu

_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to