Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Commit

Permalink
Change default listen backlog to socket_base::max_connections
Browse files Browse the repository at this point in the history
Work on #245
Related to zaphoyd/websocketpp#549

Change default listen backlog from 0 to
boost::asio::socket_base::max_connections.
Also, we'll take on the opportunity and add a configuration parameter
for this value, in the file kurento.conf.json.
  • Loading branch information
j1elo committed Apr 12, 2018
1 parent 14b54ee commit 1c95be3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion kurento.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
// "localAddress": "localhost"
//},
"path": "kurento",
"threads": 10
"threads": 10,
// Maximum queue length of pending connections (see sysctl tcp_max_syn_backlog)
// Default SOMAXCONN (128)
//"connqueue": 128,
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions server/transport/websocket/WebSocketTransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ const std::string DEFAULT_LOCAL_ADDRESS = "localhost";
const ushort WEBSOCKET_PORT_DEFAULT = 8888;
const std::string WEBSOCKET_PATH_DEFAULT = "kurento";
const int WEBSOCKET_THREADS_DEFAULT = 10;
const int WEBSOCKET_CONNQUEUE_DEFAULT =
boost::asio::socket_base::max_connections;

class configuration_exception : public std::exception
{
Expand All @@ -71,6 +73,7 @@ WebSocketTransport::WebSocketTransport (const boost::property_tree::ptree
{
ushort port;
ushort securePort;
int connqueue;
std::string registrarAddress;
std::string localAddress;

Expand All @@ -81,6 +84,9 @@ WebSocketTransport::WebSocketTransport (const boost::property_tree::ptree
path = config.get<std::string> ("mediaServer.net.websocket.path",
WEBSOCKET_PATH_DEFAULT);

connqueue = config.get<uint> ("mediaServer.net.websocket.connqueue",
WEBSOCKET_CONNQUEUE_DEFAULT);

try {
n_threads = config.get<uint> ("mediaServer.net.websocket.threads");

Expand All @@ -103,6 +109,7 @@ WebSocketTransport::WebSocketTransport (const boost::property_tree::ptree
server.clear_error_channels (websocketpp::log::alevel::all);

server.init_asio (&ios);
server.set_listen_backlog (connqueue);
server.set_reuse_addr (true);
server.set_open_handler (std::bind ( (void (WebSocketTransport::*) (
WebSocketServer *, websocketpp::connection_hdl) )
Expand Down

0 comments on commit 1c95be3

Please # to comment.