Hi, my problem is simple, I have to use DuckDns on nodejs, I'm a beginner, and i hadded to my script this :
I think, DuckDns Refused connection because of nodejs is not the real one way to host website withit, and apache addon on homeassistant won't start other files than a "index.html" file...
Is anybody can help me ? Thanks ;)
// Use "npm install" and "npm run dev" to run this script named "server.js"
// But I can use "node server.js" on the path of the project too
// For "key.pem" and "fullchain.pem", I copy paste them directly by the DuckDns addons,
// I can't make anymore ".pem" files on the "./ssh/<NAME>.pem" on my homeassistant,
// don't know why ;-; ... I'm sad so
const path = require("path");
const https = require('https');
const fs = require('fs');
const express = require("express");
const socketio = require("socket.io");
const formatMessage = require("./utils/messages");
const createAdapter = require("@socket.io/redis-adapter").createAdapter;
const redis = require("redis");
require("dotenv").config();
const { createClient } = redis;
const {
userJoin,
getCurrentUser,
userLeave,
getRoomUsers,
} = require("./utils/users");
const app = express();
const httpServer = require("https").createServer({
key: fs.readFileSync('privkey.pem'),
cert: fs.readFileSync('fullchain.pem')
});
const io = socketio(httpServer);
const options = {
key: fs.readFileSync('privkey.pem'),
cert: fs.readFileSync('fullchain.pem'),
hostname: 'DOMAIN.duckdns.org',
port: 3567,
path: '---.---.---.---:3567',
method: 'POST'
};
const req = https.request(options, (res) => {
console.log('statusCode:', res.statusCode);
console.log('headers:', res.headers);
res.on('data', (d) => {
process.stdout.write(d);
});
});
// I skip the script for the website, it's just a io.on("connection", (socket) => {...
const PORT = process.env.PORT || 3568;
httpServer.listen(PORT, () => console.log(`Server running on port ${PORT}`));
In the terminal it said :
Terminal code E-Timed-Out
(so for this one, he not found the DOMAIN.duckdns.org, normal if I tr to scribe others stuff) :
[nodemon] restarting due to changes...
[nodemon] starting `node server.js`
Server running on port 3568
events.js:292
throw er; // Unhandled 'error' event
^
Error: connect ETIMEDOUT 176.152.200.170:3567
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16)
Emitted 'error' event on ClientRequest instance at:
at TLSSocket.socketErrorListener (_http_client.js:469:9)
at TLSSocket.emit (events.js:315:20)
at emitErrorNT (internal/streams/destroy.js:106:8)
at emitErrorCloseNT (internal/streams/destroy.js:74:3)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
errno: -4039,
code: 'ETIMEDOUT',
syscall: 'connect',
address: '---.---.---.---',
port: 3567
}
[nodemon] app crashed - waiting for file changes before starting...
Terminal code Err : E.Conn.Refused
(Here he found it ! YEAH! But Can't connect, no tutorials, no helping, no other help so I try here)
[nodemon] restarting due to changes...
[nodemon] starting `node server.js`
Server running on port 3568
events.js:292
throw er; // Unhandled 'error' event
^
Error: connect ECONNREFUSED 176.152.200.170:3567
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16)
Emitted 'error' event on ClientRequest instance at:
at TLSSocket.socketErrorListener (_http_client.js:469:9)
at TLSSocket.emit (events.js:315:20)
at emitErrorNT (internal/streams/destroy.js:106:8)
at emitErrorCloseNT (internal/streams/destroy.js:74:3)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
errno: -4078,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '---.---.---.---',
port: 3567
}
[nodemon] app crashed - waiting for file changes before starting...
Thanks for helping me ;)