我正在Ubuntu上工作,我正在编写一个服务器在C++中使用websocket ++库,它完美适用于来自浏览器(我在那里使用JavaScript)传入websocket连接。使用websocketpp库连接到一个c + + websocket服务器
现在我想做一些性能测试,并连接了很多自动化的“假”客户端。
为此,我想编写一个多次启动并连接到该服务器的程序。要做到这一点,我尝试下面的代码:当服务器不
2013-04-23T16:00:02 [2] fail_on_expire timer expired with message: Timeout on WebSocket handshake
:
#include "websocketpp/src/roles/client.hpp"
#include "websocketpp/src/websocketpp.hpp"
#include <boost/asio.hpp>
#include <boost/bind.hpp>
#include <boost/thread.hpp>
#include "FakeClient.h"
using boost::asio::ip::tcp;
using websocketpp::client;
FakeClient::FakeClient()
{
thisPointer = boost::shared_ptr<FakeClient>(this);
client endpoint(thisPointer);
endpoint.alog().unset_level(websocketpp::log::alevel::ALL);
endpoint.elog().unset_level(websocketpp::log::elevel::ALL);
endpoint.elog().set_level(websocketpp::log::elevel::RERROR);
endpoint.elog().set_level(websocketpp::log::elevel::FATAL);
endpoint.connect("ws://localhost:9001/");
boost::thread t(&FakeClient::run, *this);
t.join();
}
void FakeClient::run()
{
while(true)
{
// send stuff here
usleep(100);
}
}
现在,当服务器启动和假冒客户端尝试连接时,我只得到了以下错误虽然开始,但没有错误信息出现,所以肯定会有某种连接发生。但我无法弄清楚我做错了什么。是否有可能通过websocket ++ lib轻松连接2个二进制程序?
为了获得最佳的性能测试结果,我猜,websockets应该用于服务器和假客户端之间的通信。
这里谢谢你的帮助,
Koonschi
你有没有窥探过http交换?将是有用的 – ldgorman 2013-04-23 14:33:14
websockets确实支持二进制为“完全支持:RFC6455” – ldgorman 2013-04-23 14:35:05
试图增加您的conf的超时服务器 – ldgorman 2013-04-23 14:36:06