Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Posting to multiple servers #80

Open
theckld opened this issue Aug 4, 2020 · 4 comments
Open

Posting to multiple servers #80

theckld opened this issue Aug 4, 2020 · 4 comments

Comments

@theckld
Copy link

theckld commented Aug 4, 2020

Can you please add the ability to post to more multiple servers?

@animetosho
Copy link
Owner

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.

@theckld
Copy link
Author

theckld commented Aug 5, 2020

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?

@animetosho
Copy link
Owner

animetosho commented Aug 5, 2020

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.

@theckld
Copy link
Author

theckld commented Aug 5, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants