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

How to keep the connection open and also set connection timeout? #134

Open
shubsaini09 opened this issue Jun 15, 2023 · 0 comments
Open

Comments

@shubsaini09
Copy link

shubsaini09 commented Jun 15, 2023

Hello,

I have a huge traffic for my API and I feel making a connection for each request is not right. I want to know if there is way to keep the connection open or some sort of pooling is available in the library. Below is my sample code where the function conn is called on each request.

function conn() {
       ............
       ............
	const failover = new stompit.ConnectFailover(servers, reconnectOptions);
	failover.connect((error, client) => {
		if (error) {
			throw new Error(error);
		}
		const frame = client.send(sendHeaders);
		frame.write('my message');
		frame.end();
		client.disconnect();
		return 'success';
	});
}

Also, how do we set a connection timeout? I want to throw an error if the connection is taking long to establish. The default is 3000 but it does not work. I even tried setting it up separately and even that did not work.

my config is as below

{
	host,
	connectHeaders: {
		login,
		passcode,
	},
	ssl: true,
	port: 61614,
	timeout: 10000
}
@shubsaini09 shubsaini09 changed the title How to keep the connection open? How to keep the connection open and also set connection timeout? Jun 15, 2023
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

1 participant