Posting to multiple servers
Can you please add the ability to post to more multiple servers?
The functionality is there - you'll need to configure it via the config file as it's not exposed in the command-line argument interface.
If you specify multiple servers, it just randomly distributes posts across all the connections.
How can I specify multiple servers in the config file? I have tried adding multiple server options sections but it does not seem to work, it will only picks the last one defined. And what about header checking? its options will be related to which server if more than one are defined?
It won't work with the simple JSON based config file (which essentially uses the same interface as the command line). You'll need to use the full Javascript based config file (which means you can no longer use the JSON config file).
You can use the default config.js as a sample.
Example config file with two servers (you'll obviously need to change the details):
module.exports = {
servers: [
// server 1 (full config displayed)
{
// connection options - see the following pages for full documentation
// non-SSL: https://nodejs.org/api/net.html#net_socket_connect_options_connectlistener
// SSL: https://nodejs.org/api/tls.html#tls_tls_connect_options_callback
connect: { // connection options
host: 'localhost',
port: null, // null => if server.secure, port=563, else, port=119
// SSL options
rejectUnauthorized: true,
highWaterMark: 0, // disable node's internal bufferring to improve our timings (we always send full chunks, so bufferring by node isn't needed)
},
secure: false, // set to true to use SSL
user: '',
password: '',
// note that these times are specified in miliseconds
timeout: 30000, // 30000ms = 30 seconds
connTimeout: 30000, // 30 seconds
postTimeout: 150000, // 2.5 minutes
reconnectDelay: 15000, // 15 seconds
connectRetries: 1,
requestRetries: 5, // how many times to retry an interrupted request
retryBadResp: false, // enable retrying if a bad response is received
postRetries: 1, // how many times to retry if server returns 441 response to posted article
postRetryDelay: 0, // delay post retries (above option) by this many milliseconds
postFailReconnect: false, // treat post failure like a connection-level error; postRetries and postRetryDelay settings are ignored if true
errorTeardown: false, // false = gracefully close bad connections, true = forcefully destroy them
closeTimeout: 10000, // 10 seconds; wait period before forcefully dropping gracefully closed connections
keepAlive: false, // always reconnect on error, even if not needed
onPostTimeout: null, // list of actions (strings) to take if server sends no response to a post; values can be 'retry', 'strip-hdr=X' and 'ignore'; if not set (null), defaults to ['retry','retry','retry'...] where the number of elements == requestRetries
tcpKeepAlive: false, // false to disable, otherwise set a number for probe interval (in ms)
uploadChunkSize: 192*1024, // break up post into chunks of this size when uploading; 0 to disable chunking
postMethod: 'POST', // command to use when posting; can be POST, IHAVE, XREPLIC or TAKETHIS
postConnections: 3, // number of connections for posting
checkConnections: 0, // number of connections used for checking
},
// server 2
{
// connection options - see the following pages for full documentation
// non-SSL: https://nodejs.org/api/net.html#net_socket_connect_options_connectlistener
// SSL: https://nodejs.org/api/tls.html#tls_tls_connect_options_callback
connect: { // connection options
host: 'localhost',
port: null, // null => if server.secure, port=563, else, port=119
// SSL options
rejectUnauthorized: true,
highWaterMark: 0, // disable node's internal bufferring to improve our timings (we always send full chunks, so bufferring by node isn't needed)
},
secure: false, // set to true to use SSL
user: '',
password: '',
// note that these times are specified in miliseconds
timeout: 30000, // 30000ms = 30 seconds
connTimeout: 30000, // 30 seconds
postTimeout: 150000, // 2.5 minutes
reconnectDelay: 15000, // 15 seconds
connectRetries: 1,
requestRetries: 5, // how many times to retry an interrupted request
retryBadResp: false, // enable retrying if a bad response is received
postRetries: 1, // how many times to retry if server returns 441 response to posted article
postRetryDelay: 0, // delay post retries (above option) by this many milliseconds
postFailReconnect: false, // treat post failure like a connection-level error; postRetries and postRetryDelay settings are ignored if true
errorTeardown: false, // false = gracefully close bad connections, true = forcefully destroy them
closeTimeout: 10000, // 10 seconds; wait period before forcefully dropping gracefully closed connections
keepAlive: false, // always reconnect on error, even if not needed
onPostTimeout: null, // list of actions (strings) to take if server sends no response to a post; values can be 'retry', 'strip-hdr=X' and 'ignore'; if not set (null), defaults to ['retry','retry','retry'...] where the number of elements == requestRetries
tcpKeepAlive: false, // false to disable, otherwise set a number for probe interval (in ms)
uploadChunkSize: 192*1024, // break up post into chunks of this size when uploading; 0 to disable chunking
postMethod: 'POST', // command to use when posting; can be POST, IHAVE, XREPLIC or TAKETHIS
postConnections: 3, // number of connections for posting
checkConnections: 0, // number of connections used for checking
},
],
isFullConfig: true
};
Unfortunately, it's a bit complicated at the moment, as there's no simple interface to get it to work. I might try to come up with something to simplify configuring multiple servers eventually.
Nice! I managed to get it working now. Thanks. It would also be great if you can add some failover mechanism in case one article failed to post at one server to retry posting it with another server.