【发布时间】:2014-08-14 16:04:28
【问题描述】:
我安装了一个 Openfire 服务器,并创建了 2 个使用 XMPP 协议互相聊天的用户。
我从这里获取了一个示例 PHP 项目:http://www.experts-exchange.com/Programming/Languages/Scripting/PHP/Q_26533833.html
这是代码sn-p:
<?php
// activate full error reporting
//error_reporting(E_ALL & E_STRICT);
include 'XMPPHP/XMPP.php';
#Use XMPPHP_Log::LEVEL_VERBOSE to get more logging for error reports
#If this doesn't work, are you running 64-bit PHP with < 5.2.6?
$conn = new XMPPHP_XMPP('pc27', 5222, 'user1', 'user1', 'xmpphp', 'pc27', $printlog=true, $loglevel=XMPPHP_Log::LEVEL_INFO);
try {
$conn->connect();
$conn->processUntil('session_start');
$conn->presence();
$conn->message('user2@pc27', 'This is a test message!');
$conn->disconnect();
} catch(XMPPHP_Exception $e) {
die($e->getMessage());
}
但是当我点击 url:localhost/Chat/sendmessage_example.php 时,我在屏幕上收到以下消息:
1403610021 [INFO]: Connecting to tcp://pc27:5222 Connecting to tcp://pc27:5222 user1@pc27 1403610021 [INFO]: Starting TLS encryption
Warning: stream_socket_enable_crypto(): this stream does not support SSL/crypto in D:\xampp\htdocs\Chat\XMPPHP\XMPP.php on line 392
Fatal error: Maximum execution time of 30 seconds exceeded in D:\xampp\htdocs\Chat\XMPPHP\XMLStream.php on line 475
我尝试了什么:ini_set("max_execution_time", 300);不起作用(同样的错误再次出现)。
另外,我不明白为什么它连接到 "tcp://pc27:5222" ? “tcp”不应该是“localhost”还是本地ip?这是超时错误的原因吗?
【问题讨论】:
-
到目前为止我做了什么: 1) 在connect() 和processUntil() 之后添加了一行: $conn->presence($status='Controller available.'); 2) 取消注释 xampp/php 下 php.ini 中的行:extension=php_openssl.dll 3) 在 PATH 变量下添加 libeay32.dll 的路径。运行示例 PHPINFO 页面还显示 OpenSSL 已启用。现在,当我尝试连接时,我得到以下信息:Connecting to tcp://pc27:5222 user1@pc27
标签: php timeout xmpp chat openfire