- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 217
 
Open
Labels
Description
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