React/ZMQ/Ratchet - Websocket server response

后端 未结 2 1572
广开言路
广开言路 2021-01-26 16:02

I\'ve currently got a web socket server running and working with Ratchet PHP. I\'m not at the stage where I want external scripts to communicate with my server. I can successful

相关标签:
2条回答
  • 2021-01-26 16:07

    You have this line in your pull.php:

    echo $socket->recv();
    

    Push socket is for sending messages, not receiving them. That's probably where the exception comes from.

    Also: The first parameter of method on() on pull sockets should be 'message'.

    $pull->on('message', array($pusher, 'onPull'));
    
    0 讨论(0)
  • 2021-01-26 16:09

    In your pull.php file, you've got a REQ socket connecting to a PULL socket. Check out the docs to see compatible socket pairs. In particular, it appears that you want a REQ-REP pair so that your client can request data and your server replies with a response. You'd use PUSH-PULL if your server queues up data ready for the next client, and then your client pulls whatever is next from the queue.

    In either event, you cannot connect a REQ socket to a PULL socket or a PUSH socket.

    I don't fully understand your use case or communication architecture from the listed code or naming scheme, so I don't know how much more detail I can give than that, feel free to clarify what's going on and I might be able to advise more definitively what socket strategy you should be using.

    0 讨论(0)
提交回复
热议问题