我正在使用PHP Stomp 客户端发送 stomp 消息。
我想在后台打开一个持久连接,偶尔发送消息。
但是,如果在打开连接后(在 send() 上)发生连接错误,我找不到处理连接错误的方法。
例如,运行时:
<?php
$stomp = new Stomp('tcp://localhost:61613');
sleep(5); // Connection goes down in the meantime
$result = $stomp->send('/topic/test', 'TEST');
print "send " . ($result ? "successful\n": "failed\n");
?>
输出:send successful
即使连接在 中断开sleep()
,也send()
始终返回 true。
文档不是很有帮助,Stomp::error()
并且在stomp_connect_error()
返回时也没有太大帮助false
。
作为临时解决方案,我在每个send()
.
有没有更好的方法来捕获连接错误?