handshake failed due to invalid connection header

when i try to connect with moonlink i get this: the server is on my pc i tried both localhost and 127.0.0.1 and both gives the same result
No description
81 Replies
!_SREERAJ_SK
!_SREERAJ_SK•5w ago
what version of lavalink and moonlink you using??
Ehi
EhiOP•5w ago
moonlink 4.60.4 and lavalink 4.1.1
!_SREERAJ_SK
!_SREERAJ_SK•5w ago
can u share the part of code where u create moonlink manager and the part where u initialize the manager
Ehi
EhiOP•5w ago
sure
// index.ts

core.moonlink = new Manager({
options:{},
nodes: [
{
host: process.env.moonlink_host,
port: parseInt(process.env.moonlink_port),
password: process.env.moonlink_password,
secure: process.env.moonlink_secure === 'true',
identifier:'main'
}
],
sendPayload: (guildId: string, payload: string) => {
const guild = core.guilds.cache.get(guildId);
if (guild) guild.shard.send(JSON.parse(payload));
}
});

core.moonlink.on('nodeReady', (node, stats) => {
console.log(`Node ${node.identifier} is ready`, stats);
});

core.moonlink.on('nodeError',(node,error)=>{
console.log(`Could not connect to node ${node.identifier}`);
console.log(error);
});

core.on(Events.Raw,(packet)=>{
core.moonlink.packetUpdate(packet);
});

// ready.ts

const e: Event<'clientReady'> = {
name: 'clientReady',
async once(core) {

//...
core.moonlink.init(core.user.id)
.then(() => console.log('Initialized moonlink!'))
.catch(r => {
console.log(`Could not initialize moonlink.`);
console.error(r);
});
//...

},
}
// index.ts

core.moonlink = new Manager({
options:{},
nodes: [
{
host: process.env.moonlink_host,
port: parseInt(process.env.moonlink_port),
password: process.env.moonlink_password,
secure: process.env.moonlink_secure === 'true',
identifier:'main'
}
],
sendPayload: (guildId: string, payload: string) => {
const guild = core.guilds.cache.get(guildId);
if (guild) guild.shard.send(JSON.parse(payload));
}
});

core.moonlink.on('nodeReady', (node, stats) => {
console.log(`Node ${node.identifier} is ready`, stats);
});

core.moonlink.on('nodeError',(node,error)=>{
console.log(`Could not connect to node ${node.identifier}`);
console.log(error);
});

core.on(Events.Raw,(packet)=>{
core.moonlink.packetUpdate(packet);
});

// ready.ts

const e: Event<'clientReady'> = {
name: 'clientReady',
async once(core) {

//...
core.moonlink.init(core.user.id)
.then(() => console.log('Initialized moonlink!'))
.catch(r => {
console.log(`Could not initialize moonlink.`);
console.error(r);
});
//...

},
}
btw moonlink says initialized like normal and only the lavalink terminal says that it couldn't connect
!_SREERAJ_SK
!_SREERAJ_SK•5w ago
@ComicallyBad hlpp @UnschooledGamer try secure: false , my guess
UnschooledGamer
UnschooledGamer•5w ago
I'll check, it's been a while since I tested moonlink.js
UnschooledGamer
UnschooledGamer•5w ago
No description
No description
UnschooledGamer
UnschooledGamer•5w ago
CC: @Ehi
ComicallyBad
ComicallyBad•5w ago
Should first try just manually inputting all the node info in case its just not accessing process.env properly. Then turn secure off. See if that changes anything
1Lucas1.apk
1Lucas1.apk•4w ago
@Ehi Did you manage to solve the problem?
Ehi
EhiOP•4w ago
not really all I did was try this and it didn't work
1Lucas1.apk
1Lucas1.apk•4w ago
Can you provide me with all the logs and debug logs? From what I saw, it's not the port they mentioned, nor would it be requesting it. on moonlink just put this information options*
logFile: {
log: true,
path: "moonlink.log",
}
logFile: {
log: true,
path: "moonlink.log",
}
core.moonlink = new Manager({
options:{
logFile: {
log: true,
path: "moonlink.log",
}
},
nodes: [
{
host: process.env.moonlink_host,
port: parseInt(process.env.moonlink_port),
password: process.env.moonlink_password,
secure: process.env.moonlink_secure === 'true',
identifier:'main'
}
],
sendPayload: (guildId: string, payload: string) => {
const guild = core.guilds.cache.get(guildId);
if (guild) guild.shard.send(JSON.parse(payload));
}
});
core.moonlink = new Manager({
options:{
logFile: {
log: true,
path: "moonlink.log",
}
},
nodes: [
{
host: process.env.moonlink_host,
port: parseInt(process.env.moonlink_port),
password: process.env.moonlink_password,
secure: process.env.moonlink_secure === 'true',
identifier:'main'
}
],
sendPayload: (guildId: string, payload: string) => {
const guild = core.guilds.cache.get(guildId);
if (guild) guild.shard.send(JSON.parse(payload));
}
});
Ehi
EhiOP•4w ago
[2025-09-05T16:46:40.094Z] Moonlink.js > Database > Mode set to WAL
[2025-09-05T16:46:40.098Z] Moonlink.js > Sources are enabled
[2025-09-05T16:46:40.098Z] Moonlink.js > Node > Connect > Attempting connection to main (127.0.0.1:2333) UUID: e82d59fbebbfb259e8190f432cb43e2a3baae40cc16d38c8123cd11181e0230f
[2025-09-05T16:46:40.099Z] Moonlink.js > initialized with clientId(1275629051758907493), ready to go!
[2025-09-05T16:46:40.099Z] Moonlink.js > Version: 4.60.4
[2025-09-05T16:46:40.099Z] Moonlink.js > environment: Node.js; version: v22.6.0
[2025-09-05T16:46:40.102Z] Moonlink.js > Node (main) is ready for attempting to connect.
[2025-09-05T16:46:40.102Z] Moonlink.js > Node > Connect > WebSocket handlers attached to main
[2025-09-05T16:46:40.107Z] Moonlink.js > Deezer > Source loaded
[2025-09-05T16:46:40.108Z] Moonlink.js > Source > Deezer added
[2025-09-05T16:46:40.109Z] Moonlink.js > Spotify > source loaded
[2025-09-05T16:46:40.110Z] Moonlink.js > Source > Spotify added
[2025-09-05T16:46:40.094Z] Moonlink.js > Database > Mode set to WAL
[2025-09-05T16:46:40.098Z] Moonlink.js > Sources are enabled
[2025-09-05T16:46:40.098Z] Moonlink.js > Node > Connect > Attempting connection to main (127.0.0.1:2333) UUID: e82d59fbebbfb259e8190f432cb43e2a3baae40cc16d38c8123cd11181e0230f
[2025-09-05T16:46:40.099Z] Moonlink.js > initialized with clientId(1275629051758907493), ready to go!
[2025-09-05T16:46:40.099Z] Moonlink.js > Version: 4.60.4
[2025-09-05T16:46:40.099Z] Moonlink.js > environment: Node.js; version: v22.6.0
[2025-09-05T16:46:40.102Z] Moonlink.js > Node (main) is ready for attempting to connect.
[2025-09-05T16:46:40.102Z] Moonlink.js > Node > Connect > WebSocket handlers attached to main
[2025-09-05T16:46:40.107Z] Moonlink.js > Deezer > Source loaded
[2025-09-05T16:46:40.108Z] Moonlink.js > Source > Deezer added
[2025-09-05T16:46:40.109Z] Moonlink.js > Spotify > source loaded
[2025-09-05T16:46:40.110Z] Moonlink.js > Source > Spotify added
MEE6
MEE6•4w ago
GG @Ehi, you just advanced to level 1!
1Lucas1.apk
1Lucas1.apk•4w ago
WebSocket handlers attached to main hmmm let's take a look at the source code do you have access to node_modules? if you have it in /moonlink.js/dist/src/entities/Node.js on line 74 around there let headers = { Authorization: this.password, "User-Id": this.manager.options.clientId, "Client-Name": this.manager.options.clientName, }; if (this.manager.options.resume && sessionId) { headers["Session-Id"] = sessionId; this.manager.emit("debug", Moonlink.js > Node > Connect > Using resume session ID: ${sessionId} for ${this.identifier}); } console.log(headers) below that put @Ehi
Ehi
EhiOP•4w ago
put what?
Ehi
EhiOP•4w ago
the headers are already there
No description
1Lucas1.apk
1Lucas1.apk•4w ago
on line 77 I noticed that there is a header that is placed there put console.log(headers) then send me what returns
Ehi
EhiOP•4w ago
No description
Ehi
EhiOP•4w ago
added the log to below l77 btw
1Lucas1.apk
1Lucas1.apk•4w ago
in /dist/src/services/Websocket.js on the line
1Lucas1.apk
1Lucas1.apk•4w ago
No description
1Lucas1.apk
1Lucas1.apk•4w ago
console.log(options) on line 43
Ehi
EhiOP•4w ago
it says upgrade here
No description
Ehi
EhiOP•4w ago
maybe its changed somewhere else? or lavalink thinks its keep alive for some reason??
1Lucas1.apk
1Lucas1.apk•4w ago
why is it giving an error with header[keep-alive] I want to know where it is coming from
1Lucas1.apk
1Lucas1.apk•4w ago
No description
1Lucas1.apk
1Lucas1.apk•4w ago
if it is a wrong key or something undefined Have you tried using "localhost" or "0.0.0.0" as host?
Ehi
EhiOP•4w ago
i tried localhost but not 0.0.0.0
1Lucas1.apk
1Lucas1.apk•4w ago
We can also test postman to see if it's not a problem with lavalink making a connection through WS if it works it is in the package through WebSocket something that is incorrect If it doesn't work, there's a problem with Lavalink.
Ehi
EhiOP•4w ago
do you think you can test that? i don't have postman installed rn
1Lucas1.apk
1Lucas1.apk•4w ago
I think so @Ehi try again later
1Lucas1.apk
1Lucas1.apk•4w ago
GitHub
GitHub - Ecliptia/moonlink.js: MoonLink.js is a simple package for ...
MoonLink.js is a simple package for lavalink client, perfect for you to create your discord bot with songs, and very simple and easy to use. - GitHub - Ecliptia/moonlink.js: MoonLink.js is a simpl...
1Lucas1.apk
1Lucas1.apk•4w ago
and see if it fixed the problem if you don't let me know
UnschooledGamer
UnschooledGamer•4w ago
"if you do let me know" ig 😄
1Lucas1.apk
1Lucas1.apk•4w ago
There are people who disappear from the face of the earth when I test with it, so I don't have to do it :)
Ehi
EhiOP•4w ago
still the same :|
No description
Ehi
EhiOP•4w ago
i even checked the code in node modules and the latest commit to make sure I downloaded the correct version and it looks like i did
No description
Ehi
EhiOP•4w ago
btw i noticed that I have event listeners for nodeReady and nodeError but neither of them trigger
MEE6
MEE6•4w ago
GG @Ehi, you just advanced to level 2!
Ehi
EhiOP•4w ago
i don't know if that helps
!_SREERAJ_SK
!_SREERAJ_SK•4w ago
its not connecting to lavalink like successfully connecting to the lavalink , so they dont fire if im right
1Lucas1.apk
1Lucas1.apk•4w ago
Wait, I'll see how to activate the Lavalink debugs I think this way we can see what he accuses is incorrect.
1Lucas1.apk
1Lucas1.apk•4w ago
Let's do the following, in application.yml change the Info for this debug one, it should certainly show something
logging:
level:
root: DEBUG
lavalink: DEBUG
lavalink.server.io.SocketContext: DEBUG
com.sedmelluq.discord.lavaplayer.tools.ExceptionTools: DEBUG
dev.lavalink.youtube: DEBUG

request:
enabled: true
includeClientInfo: true
includeHeaders: true
includeQueryString: true
includePayload: true
logging:
level:
root: DEBUG
lavalink: DEBUG
lavalink.server.io.SocketContext: DEBUG
com.sedmelluq.discord.lavaplayer.tools.ExceptionTools: DEBUG
dev.lavalink.youtube: DEBUG

request:
enabled: true
includeClientInfo: true
includeHeaders: true
includeQueryString: true
includePayload: true
@Ehi
UnschooledGamer
UnschooledGamer•4w ago
Root would throw alot stuffs 🙃
Ehi
EhiOP•4w ago
this is the new full log
No description
UnschooledGamer
UnschooledGamer•4w ago
@1Lucas1.apk look there Connection: "keep-alive"
1Lucas1.apk
1Lucas1.apk•4w ago
the worst thing is that this is not defined in the requests .
UnschooledGamer
UnschooledGamer•4w ago
Hmm Saw that when I was trying to check the issue You're on vsc, Lucas? (not vscodium)
1Lucas1.apk
1Lucas1.apk•4w ago
WebStorm
UnschooledGamer
UnschooledGamer•4w ago
🙃 VSCode.dev would work ig let him do " live share " To you. Then you can collaboratively try to fix it
1Lucas1.apk
1Lucas1.apk•4w ago
but I have vsc
UnschooledGamer
UnschooledGamer•4w ago
Oh Ok Then use vsc
1Lucas1.apk
1Lucas1.apk•4w ago
What is the name of the plugin to do in collaboration?
UnschooledGamer
UnschooledGamer•4w ago
Ask him to share his workspace with live share extension/plugin You too download it on your side
UnschooledGamer
UnschooledGamer•4w ago
Live Share - Visual Studio Marketplace
Extension for Visual Studio Code - Real-time collaborative development from the comfort of your favorite tools.
1Lucas1.apk
1Lucas1.apk•4w ago
I downloaded it and I'll send you the invite
UnschooledGamer
UnschooledGamer•4w ago
Not me 🙃
1Lucas1.apk
1Lucas1.apk•4w ago
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa
UnschooledGamer
UnschooledGamer•4w ago
That guy needs to....
1Lucas1.apk
1Lucas1.apk•4w ago
I understand now
UnschooledGamer
UnschooledGamer•4w ago
You'll join he's workspace 😀
1Lucas1.apk
1Lucas1.apk•4w ago
@Ehi install this plugin
Ehi
EhiOP•4w ago
i have it
1Lucas1.apk
1Lucas1.apk•4w ago
activate it and send me the code to write and read so I can fix it, I can't reproduce this error on my machine I'm just going to mess with node_modules
Ehi
EhiOP•4w ago
1Lucas1.apk
1Lucas1.apk•4w ago
it has to be in the folder
Ehi
EhiOP•4w ago
what folder
1Lucas1.apk
1Lucas1.apk•4w ago
to the bot while I fix it, I'll test it on the server
Ehi
EhiOP•4w ago
i somehow closed vscode
Ehi
EhiOP•4w ago
Visual Studio Code for the Web
Build with Visual Studio Code, anywhere, anytime, entirely in your browser.
1Lucas1.apk
1Lucas1.apk•4w ago
strangely I don't see node_modules
{
"$schema": "http://json.schemastore.org/vsls",
"gitignore": "exclude",
"excludeFiles": [
".env",
".vscode",
"! node_modules"
],
"hideFiles": [
"build"
]
}
{
"$schema": "http://json.schemastore.org/vsls",
"gitignore": "exclude",
"excludeFiles": [
".env",
".vscode",
"! node_modules"
],
"hideFiles": [
"build"
]
}
.vsls.json create this file and put this, and restart vsc @Ehi for me to fill the node_modules
Ehi
EhiOP•4w ago
that doesn't work how about we try the webstorm share feature
1Lucas1.apk
1Lucas1.apk•4w ago
yeah
1Lucas1.apk
1Lucas1.apk•4w ago
@UnschooledGamer now that I noticed, he's using bun There are some packages in bun that work differently than the native node ones
1Lucas1.apk
1Lucas1.apk•4w ago
GitHub
GitHub - Ecliptia/moonlink.js: MoonLink.js is a simple package for ...
MoonLink.js is a simple package for lavalink client, perfect for you to create your discord bot with songs, and very simple and easy to use. - GitHub - Ecliptia/moonlink.js: MoonLink.js is a simpl...
1Lucas1.apk
1Lucas1.apk•4w ago
now it should work
UnschooledGamer
UnschooledGamer•4w ago
Oh. Moonlink should've detected that, in the logs he sent for Moonlink.js
1Lucas1.apk
1Lucas1.apk•4w ago
sim, estranhamente ainda deu nodejs ali yes, strangely it still gave nodejs there I noticed from the headers I saw somewhere bun/version that's what I saw

Did you find this page helpful?