- Brief Intro
I'm now using stomp to connect with ActiveMQ based on a PHP site running on apache server. The Stomp can run in bash but can't run in apache.
- Preparation
I install stomp by
pecl install stomp
and modify the php.ini with
extension=stomp.so
I have a 'index.php' like this:
<?php
echo 'runing-';
/* connection */
try {
$stomp = new Stomp('tcp://localhost:61613');
echo 'connecting-';
} catch(StompException $e) {
die('Error! Connection failed: ' . $e->getMessage());
}
$stomp->send('/queue/test', 'Hello from PHP');
echo 'finished.';
/* close connection */
unset($stomp);
?>
- Start Working
Firstly, I run with
$ php index.php
And it echo as my expectation:
$ php index.php
runing-connecting-finished.
Then I open it in browser:
http://localhost/index.php
It reports
runing-Error! Connection failed: Unable to connect to localhost:61613
- Question
I've searching resolution for this error all day... I guess apache block the request from stomp since it runs successfully in bash.
What should I do to fix this bug?
Thanks really.