Ratchet Push Server Tutorial issues





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







1















I am trying to get the ratchet push tutorial to work.



http://socketo.me/docs/push



I am doing exactly what the tutorial is saying but no messages will be received by my subscriber.



My server.php



<?php
require dirname(__DIR__) . '/vendor/autoload.php';

$loop = ReactEventLoopFactory::create();
$pusher = new MyAppPusher;

// Listen for the web server to make a ZeroMQ push after an ajax request
$context = new ReactZMQContext($loop);
$pull = $context->getSocket(ZMQ::SOCKET_PULL);
$pull->bind('tcp://127.0.0.1:5555'); // Binding to 127.0.0.1 means the only client that can connect is itself
$pull->on('message', array($pusher, 'onBlogEntry'));

// Set up our WebSocket server for clients wanting real-time updates
$webSock = new ReactSocketServer('0.0.0.0:8080', $loop); // Binding to 0.0.0.0 means remotes can connect
$webServer = new RatchetServerIoServer(
new RatchetHttpHttpServer(
new RatchetWebSocketWsServer(
new RatchetWampWampServer(
$pusher
)
)
),
$webSock
);

$loop->run();


My addblog.php



<?php
// post.php ???
// This all was here before ;)
$entryData = array(
'category' => 'kittensCategory'
, 'title' => 'Test'
, 'article' => 'Test'
, 'when' => time()
);

$context = new ZMQContext();
$socket = $context->getSocket(ZMQ::SOCKET_PUSH, 'my pusher');
$socket->connect("tcp://localhost:5555");

$socket->send(json_encode($entryData));


And my listener.html



    <script src="autobahn.js"></script>
<script>
var conn = new ab.Session('ws://localhost:8080',
function() {
conn.subscribe('kittensCategory', function(topic, data) {
// This is where you would add the new article to the DOM (beyond the scope of this tutorial)
console.log('New article published to category "' + topic + '" : ' + data.title);
});
},
function() {
console.warn('WebSocket connection closed');
},
{'skipSubprotocolCheck': true}
);
</script>


And my Pusher.php



<?php
namespace MyApp;
use RatchetConnectionInterface;
use RatchetWampWampServerInterface;

class Pusher implements WampServerInterface {
/**
* A lookup of all the topics clients have subscribed to
*/
protected $subscribedTopics = array();

public function onSubscribe(ConnectionInterface $conn, $topic) {
echo "Hello to: ".$topic;
$this->subscribedTopics[$topic->getId()] = $topic;
}

/**
* @param string JSON'ified string we'll receive from ZeroMQ
*/
public function onBlogEntry($entry) {
$entryData = json_decode($entry, true);
echo "gallogallo";
// If the lookup topic object isn't set there is no one to publish to
if (!array_key_exists($entryData['category'], $this->subscribedTopics))
{
return;
}

$topic = $this->subscribedTopics[$entryData['category']];

// re-send the data to all the clients subscribed to that category
$topic->broadcast($entryData);
}


I do not receive any errors or warnings.
When I try to call addblog.php nothing is happening and I do not understand why.



Any hints maybe? I am testing this with XAMPP and Windows 10.










share|improve this question































    1















    I am trying to get the ratchet push tutorial to work.



    http://socketo.me/docs/push



    I am doing exactly what the tutorial is saying but no messages will be received by my subscriber.



    My server.php



    <?php
    require dirname(__DIR__) . '/vendor/autoload.php';

    $loop = ReactEventLoopFactory::create();
    $pusher = new MyAppPusher;

    // Listen for the web server to make a ZeroMQ push after an ajax request
    $context = new ReactZMQContext($loop);
    $pull = $context->getSocket(ZMQ::SOCKET_PULL);
    $pull->bind('tcp://127.0.0.1:5555'); // Binding to 127.0.0.1 means the only client that can connect is itself
    $pull->on('message', array($pusher, 'onBlogEntry'));

    // Set up our WebSocket server for clients wanting real-time updates
    $webSock = new ReactSocketServer('0.0.0.0:8080', $loop); // Binding to 0.0.0.0 means remotes can connect
    $webServer = new RatchetServerIoServer(
    new RatchetHttpHttpServer(
    new RatchetWebSocketWsServer(
    new RatchetWampWampServer(
    $pusher
    )
    )
    ),
    $webSock
    );

    $loop->run();


    My addblog.php



    <?php
    // post.php ???
    // This all was here before ;)
    $entryData = array(
    'category' => 'kittensCategory'
    , 'title' => 'Test'
    , 'article' => 'Test'
    , 'when' => time()
    );

    $context = new ZMQContext();
    $socket = $context->getSocket(ZMQ::SOCKET_PUSH, 'my pusher');
    $socket->connect("tcp://localhost:5555");

    $socket->send(json_encode($entryData));


    And my listener.html



        <script src="autobahn.js"></script>
    <script>
    var conn = new ab.Session('ws://localhost:8080',
    function() {
    conn.subscribe('kittensCategory', function(topic, data) {
    // This is where you would add the new article to the DOM (beyond the scope of this tutorial)
    console.log('New article published to category "' + topic + '" : ' + data.title);
    });
    },
    function() {
    console.warn('WebSocket connection closed');
    },
    {'skipSubprotocolCheck': true}
    );
    </script>


    And my Pusher.php



    <?php
    namespace MyApp;
    use RatchetConnectionInterface;
    use RatchetWampWampServerInterface;

    class Pusher implements WampServerInterface {
    /**
    * A lookup of all the topics clients have subscribed to
    */
    protected $subscribedTopics = array();

    public function onSubscribe(ConnectionInterface $conn, $topic) {
    echo "Hello to: ".$topic;
    $this->subscribedTopics[$topic->getId()] = $topic;
    }

    /**
    * @param string JSON'ified string we'll receive from ZeroMQ
    */
    public function onBlogEntry($entry) {
    $entryData = json_decode($entry, true);
    echo "gallogallo";
    // If the lookup topic object isn't set there is no one to publish to
    if (!array_key_exists($entryData['category'], $this->subscribedTopics))
    {
    return;
    }

    $topic = $this->subscribedTopics[$entryData['category']];

    // re-send the data to all the clients subscribed to that category
    $topic->broadcast($entryData);
    }


    I do not receive any errors or warnings.
    When I try to call addblog.php nothing is happening and I do not understand why.



    Any hints maybe? I am testing this with XAMPP and Windows 10.










    share|improve this question



























      1












      1








      1








      I am trying to get the ratchet push tutorial to work.



      http://socketo.me/docs/push



      I am doing exactly what the tutorial is saying but no messages will be received by my subscriber.



      My server.php



      <?php
      require dirname(__DIR__) . '/vendor/autoload.php';

      $loop = ReactEventLoopFactory::create();
      $pusher = new MyAppPusher;

      // Listen for the web server to make a ZeroMQ push after an ajax request
      $context = new ReactZMQContext($loop);
      $pull = $context->getSocket(ZMQ::SOCKET_PULL);
      $pull->bind('tcp://127.0.0.1:5555'); // Binding to 127.0.0.1 means the only client that can connect is itself
      $pull->on('message', array($pusher, 'onBlogEntry'));

      // Set up our WebSocket server for clients wanting real-time updates
      $webSock = new ReactSocketServer('0.0.0.0:8080', $loop); // Binding to 0.0.0.0 means remotes can connect
      $webServer = new RatchetServerIoServer(
      new RatchetHttpHttpServer(
      new RatchetWebSocketWsServer(
      new RatchetWampWampServer(
      $pusher
      )
      )
      ),
      $webSock
      );

      $loop->run();


      My addblog.php



      <?php
      // post.php ???
      // This all was here before ;)
      $entryData = array(
      'category' => 'kittensCategory'
      , 'title' => 'Test'
      , 'article' => 'Test'
      , 'when' => time()
      );

      $context = new ZMQContext();
      $socket = $context->getSocket(ZMQ::SOCKET_PUSH, 'my pusher');
      $socket->connect("tcp://localhost:5555");

      $socket->send(json_encode($entryData));


      And my listener.html



          <script src="autobahn.js"></script>
      <script>
      var conn = new ab.Session('ws://localhost:8080',
      function() {
      conn.subscribe('kittensCategory', function(topic, data) {
      // This is where you would add the new article to the DOM (beyond the scope of this tutorial)
      console.log('New article published to category "' + topic + '" : ' + data.title);
      });
      },
      function() {
      console.warn('WebSocket connection closed');
      },
      {'skipSubprotocolCheck': true}
      );
      </script>


      And my Pusher.php



      <?php
      namespace MyApp;
      use RatchetConnectionInterface;
      use RatchetWampWampServerInterface;

      class Pusher implements WampServerInterface {
      /**
      * A lookup of all the topics clients have subscribed to
      */
      protected $subscribedTopics = array();

      public function onSubscribe(ConnectionInterface $conn, $topic) {
      echo "Hello to: ".$topic;
      $this->subscribedTopics[$topic->getId()] = $topic;
      }

      /**
      * @param string JSON'ified string we'll receive from ZeroMQ
      */
      public function onBlogEntry($entry) {
      $entryData = json_decode($entry, true);
      echo "gallogallo";
      // If the lookup topic object isn't set there is no one to publish to
      if (!array_key_exists($entryData['category'], $this->subscribedTopics))
      {
      return;
      }

      $topic = $this->subscribedTopics[$entryData['category']];

      // re-send the data to all the clients subscribed to that category
      $topic->broadcast($entryData);
      }


      I do not receive any errors or warnings.
      When I try to call addblog.php nothing is happening and I do not understand why.



      Any hints maybe? I am testing this with XAMPP and Windows 10.










      share|improve this question
















      I am trying to get the ratchet push tutorial to work.



      http://socketo.me/docs/push



      I am doing exactly what the tutorial is saying but no messages will be received by my subscriber.



      My server.php



      <?php
      require dirname(__DIR__) . '/vendor/autoload.php';

      $loop = ReactEventLoopFactory::create();
      $pusher = new MyAppPusher;

      // Listen for the web server to make a ZeroMQ push after an ajax request
      $context = new ReactZMQContext($loop);
      $pull = $context->getSocket(ZMQ::SOCKET_PULL);
      $pull->bind('tcp://127.0.0.1:5555'); // Binding to 127.0.0.1 means the only client that can connect is itself
      $pull->on('message', array($pusher, 'onBlogEntry'));

      // Set up our WebSocket server for clients wanting real-time updates
      $webSock = new ReactSocketServer('0.0.0.0:8080', $loop); // Binding to 0.0.0.0 means remotes can connect
      $webServer = new RatchetServerIoServer(
      new RatchetHttpHttpServer(
      new RatchetWebSocketWsServer(
      new RatchetWampWampServer(
      $pusher
      )
      )
      ),
      $webSock
      );

      $loop->run();


      My addblog.php



      <?php
      // post.php ???
      // This all was here before ;)
      $entryData = array(
      'category' => 'kittensCategory'
      , 'title' => 'Test'
      , 'article' => 'Test'
      , 'when' => time()
      );

      $context = new ZMQContext();
      $socket = $context->getSocket(ZMQ::SOCKET_PUSH, 'my pusher');
      $socket->connect("tcp://localhost:5555");

      $socket->send(json_encode($entryData));


      And my listener.html



          <script src="autobahn.js"></script>
      <script>
      var conn = new ab.Session('ws://localhost:8080',
      function() {
      conn.subscribe('kittensCategory', function(topic, data) {
      // This is where you would add the new article to the DOM (beyond the scope of this tutorial)
      console.log('New article published to category "' + topic + '" : ' + data.title);
      });
      },
      function() {
      console.warn('WebSocket connection closed');
      },
      {'skipSubprotocolCheck': true}
      );
      </script>


      And my Pusher.php



      <?php
      namespace MyApp;
      use RatchetConnectionInterface;
      use RatchetWampWampServerInterface;

      class Pusher implements WampServerInterface {
      /**
      * A lookup of all the topics clients have subscribed to
      */
      protected $subscribedTopics = array();

      public function onSubscribe(ConnectionInterface $conn, $topic) {
      echo "Hello to: ".$topic;
      $this->subscribedTopics[$topic->getId()] = $topic;
      }

      /**
      * @param string JSON'ified string we'll receive from ZeroMQ
      */
      public function onBlogEntry($entry) {
      $entryData = json_decode($entry, true);
      echo "gallogallo";
      // If the lookup topic object isn't set there is no one to publish to
      if (!array_key_exists($entryData['category'], $this->subscribedTopics))
      {
      return;
      }

      $topic = $this->subscribedTopics[$entryData['category']];

      // re-send the data to all the clients subscribed to that category
      $topic->broadcast($entryData);
      }


      I do not receive any errors or warnings.
      When I try to call addblog.php nothing is happening and I do not understand why.



      Any hints maybe? I am testing this with XAMPP and Windows 10.







      php zeromq ratchet






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 16 '18 at 14:58







      Florian Sauerwein

















      asked Nov 16 '18 at 14:09









      Florian SauerweinFlorian Sauerwein

      152114




      152114
























          1 Answer
          1






          active

          oldest

          votes


















          -1














          I don't know why, but it is working very well on another system...






          share|improve this answer
























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53339484%2fratchet-push-server-tutorial-issues%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            -1














            I don't know why, but it is working very well on another system...






            share|improve this answer




























              -1














              I don't know why, but it is working very well on another system...






              share|improve this answer


























                -1












                -1








                -1







                I don't know why, but it is working very well on another system...






                share|improve this answer













                I don't know why, but it is working very well on another system...







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 16 '18 at 17:20









                Florian SauerweinFlorian Sauerwein

                152114




                152114
































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53339484%2fratchet-push-server-tutorial-issues%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Florida Star v. B. J. F.

                    Error while running script in elastic search , gateway timeout

                    Adding quotations to stringified JSON object values