Closed lnedry closed 4 months ago
How was it installed? Stun is listed as an optional dependency and typically gets installed.
Ah, I had to open an outbound port 19302 on the firewall and now the tests work. But if that port is blocked, then the timeout fails as demonstrated.
So we're good then, and this issue can be closed?
The original issue still exists. When the 10 second timeout occurs in either the get_public_ip (lines 325-328) or get_public_ip_async (lines 287-290) functions, it returns but the request to the stun server doesn't abort and doesn't timeout until 60 seconds has passed. You can see this issue by blocking port 19302 and running the test suite.
Please test this patch and see if it does the needful:
diff --git a/index.js b/index.js
index 77955e7..937f14c 100644
--- a/index.js
+++ b/index.js
@@ -287,7 +287,7 @@ exports.get_public_ip_async = async function () {
}, timeout * 1000)
// Connect to STUN Server
- const res = await this.stun.request(get_stun_server())
+ const res = await this.stun.request(get_stun_server(), { maxTimeout: (timeout - 1) * 1000 })
this.public_ip = res.getXorAddress().address
clearTimeout(timer)
return this.public_ip
@@ -324,12 +323,12 @@ exports.get_public_ip = async function (cb) {
}, timeout * 1000)
// Connect to STUN Server
- nu.stun.request(get_stun_server(), (error, res) => {
+ nu.stun.request(get_stun_server(), { maxTimeout: (timeout - 1) * 1000 }, (error, res) => {
if (timer) clearTimeout(timer)
if (error) return cb(error)
A STUN timeout does not end the test if Stun is not installed and running.
This is a fresh install of Haraka on Debian 11. Stun is not installed.
With this command, I get four errors
# time npm test
After 10 seconds I get three STUN timeouts:
After another 60 seconds the test run completes.
After installing and running stun, the tests run successfully.