【发布时间】:2014-09-01 07:04:11
【问题描述】:
- 简介
我现在正在使用 stomp 连接基于在 apache 服务器上运行的 PHP 站点的 ActiveMQ。 Stomp 可以在 bash 中运行,但不能在 apache 中运行。
- 准备
我通过
安装 stomppecl install stomp
并用
修改php.iniextension=stomp.so
我有一个像这样的“index.php”:
<?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);
?>
- 开始工作
首先,我运行
$ php index.php
这和我的预期一致:
$ php index.php
runing-connecting-finished.
然后我在浏览器中打开它:
http://localhost/index.php
它报告
runing-Error! Connection failed: Unable to connect to localhost:61613
- 问题
我整天都在寻找解决此错误的方法... 我猜 apache 会阻止来自 stomp 的请求,因为它在 bash 中成功运行。
我应该怎么做才能修复这个错误?
真的谢谢。
【问题讨论】: