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

unable to unbindSync from a publisher socket with compat mode #704

Open
Wayonb opened this issue Feb 20, 2025 · 0 comments
Open

unable to unbindSync from a publisher socket with compat mode #704

Wayonb opened this issue Feb 20, 2025 · 0 comments
Labels

Comments

@Wayonb
Copy link

Wayonb commented Feb 20, 2025

Describe the bug
I might be doing something incorrect here, but when I call unbindSync it gives the error Error: Address already in use.

Reproducing

* eslint-disable */
import zmq from 'zeromq/v5-compat.js';

function main() {
	const pub = zmq.socket("pub")
	const sub = zmq.socket("sub")

	pub.on("bind", address => {
		console.log(`Bound to ${address}`)
	})

	pub.bind("tcp://127.0.0.1:3456", err => {
		if (err) {
			throw err
		}

		sub.connect("tcp://127.0.0.1:3456")
		console.log("Subscriber connected to tcp://127.0.0.1:3456")

		sub.on("message", msg => {
			// Handle received message...
			console.log(`Received message: ${msg.toString()}`)
		})

		pub.send("message")
	})

	setTimeout(() => {
		pub.unbindSync("tcp://127.0.0.1:3456")
		process.exit(0)
	}, 2000)
}

main()
Bound to tcp://127.0.0.1:3456
Subscriber connected to tcp://127.0.0.1:3456
node_modules/zeromq/lib/compat.js:291
        this._socket.unbindSync(address);
                     ^

Error: Address already in use
    at Socket.unbindSync (node_modules/zeromq/lib/compat.js:291:22)
    at Timeout._onTimeout (file:///zeromq.js:30:7)
    at listOnTimeout (node:internal/timers:581:17)
    at process.processTimers (node:internal/timers:519:7) {
  errno: 98,
  code: 'EADDRINUSE',
  address: 'tcp://127.0.0.1:3456'
}

Node.js v20.18.3

Expected behavior
Since the address is already in use, I expected unbindSync to release the port

Tested on

  • OS: Ubuntu 24.04
  • Node.js 20
  • ZeroMQ.js version: 6.3.0
@Wayonb Wayonb added the bug label Feb 20, 2025
@Wayonb Wayonb changed the title unable to unbindSync form a publisher socket with compat mode unable to unbindSync from a publisher socket with compat mode Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant