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

Publishing messages only works some of the time #642

Open
MRyanPW opened this issue Nov 14, 2024 · 0 comments
Open

Publishing messages only works some of the time #642

MRyanPW opened this issue Nov 14, 2024 · 0 comments
Labels
defect Suspected defect such as a bug or regression

Comments

@MRyanPW
Copy link

MRyanPW commented Nov 14, 2024

Observed behavior

I'm trying to publish a very basic message to my synadia account and I get maybe one message through every couple of days using the node client, but I can send them consistently through golang.

Expected behavior

Every message sent ends up in my synadia account or an error message is thrown if there is an issue

Server and client version

server: whatever synadia is using
windows client:

> nats --version
v0.1.4

node dependency: "nats": "^2.28.2",

Host environment

Running it locally on windows 11 as well as some amazon boxes

Steps to reproduce

package.json:

{
	"dependencies": {
		"nats": "^2.28.2",
		"uuid": "^11.0.3"
	}
}

test.js:

const { connect, credsAuthenticator } = require("nats");
const fs = require('fs');
const path = require('path');
const { v4: uuidv4 } = require('uuid');

const test = async () => {
	const filePath = path.join(__dirname, './~~~synadia~~~.creds');
	const data = fs.readFileSync(filePath, 'utf8');
	const natsConnection = {
		servers: "tls://connect.ngs.global",
		authenticator: credsAuthenticator(new TextEncoder().encode(data)),
	};
	const nc = await connect(natsConnection);
	if (!nc) {
		throw new Error("NATS connection is not established");
	}
	const done = nc.closed();
	
	const transactionId = uuidv4();

	const testEmailToSend = {
			"message": "Never gonna give you up....but, actually I might. We just aren't clicking. I'm sorry, it's over. Find someone else. Or don't, I don't care. You broke my heart, Ethel, I'm not gonna let you do it again!",
			"image_url": "https://media1.tenor.com/m/x8v1oNUOmg4AAAAd/rickroll-roll.gif"
	};
	
	try {
		console.log('sending', emailToSend);
		nc.publish("communications", JSON.stringify(emailToSend));
		console.log("Sent!");
	}
	catch (error) {
		console.error("Failed to send email to: ", error);
	}
}

test();

Running node test.js shows the console logs but nothing shows up in synadia. However a golang version using the same credentials & connection information & test message shows up just fine

@MRyanPW MRyanPW added the defect Suspected defect such as a bug or regression label Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect Suspected defect such as a bug or regression
Projects
None yet
Development

No branches or pull requests

1 participant