Push Tutorial - 502 Gateway error on TCP connect.

63 views
Skip to first unread message

in...@freaworkx.com

unread,
Mar 30, 2015, 11:22:48 AM3/30/15
to ratch...@googlegroups.com
Hi

First of all thanks for all the hard work on Ratchet. We are very happy with our beloved chatroom system.

However I've been having issues with the "push integration". I have been following the ratchet push tutorial. Everything works fine, except for the ZMQ integration. I have been struggling for days and am unable to find an answer.
The problem is as follows. 

Whenever I try to do a $socket->connect in PHP.

 
   $context
= new ZMQContext(1);
   $socket
= $context->getSocket(ZMQ::SOCKET_PUSH, 'my pusher');
   $socket
->connect("ipc://127.0.0.1:5555");
   $socket
->send(json_encode(Array("message" => "hello")));


The webserver (NGINX) gives a 502 gateway error. When I check the error file I find that the PHP process crashes with SIGABRT(6)

WARNING: [pool www] child 659 exited on signal 6 (SIGABRT) after 0.016944 seconds from start
NOTICE: [pool www] child 662 started


I am using NGINX with PHP-FPM on CentOS 6 (EC2 instance).
I've installed the latest version of zmq 4.0.3 and am using PHP 5.6.7.

zmq

ZMQ extensionenabled
ZMQ extension version1.1.2
libzmq version
4.0.3



An important difference might be that I'm not using the WAMP protocol and using raw socket messages with my own JSON structure. Below you can find my server file.
Any help would be greatly appreciated I have gone back an forth from thinking it's a webserver , php, zeromq or ratchet issue and it's breaking my head :| 



This is my server file:

   
 
    $loop  
= React\EventLoop\Factory::create();
    $myserver
= new App\Server;


   
// Listen for the web server to make a ZeroMQ push after an ajax request
    $context
= new React\ZMQ\Context($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($myserver, 'onPushMessage'));


   
// Set up our WebSocket server for clients wanting real-time updates
    $webSock
= new React\Socket\Server($loop);
    $webSock
->listen(8080, '0.0.0.0'); // Binding to 0.0.0.0 means remotes can connect
    $webServer
= new Ratchet\Server\IoServer(
       
new Ratchet\Http\HttpServer(
           
new Ratchet\WebSocket\WsServer(
               $myserver
           
)
       
),
       $webSock
   
);


    $loop
->run();




If no solution is available, would there be other ways of connecting to the ratchet websocket over PHP? I just need to send a short message and disconnect. But none of the standalone PHP websocket clients seem to work either.


Reply all
Reply to author
Forward
0 new messages