Stream will randomly stop working after a long time.
moonstar-x opened this issue · 0 comments
moonstar-x commented
🐛 Describe the Bug
After something like 2-3 days, the stream may randomly stop working because it seems that the websocket connection is closed without notice.
Restarting the bot will fix this issue.
✏️ Steps to Reproduce
It happens randomly which makes this really hard to debug. :/
😕 Expected Behavior
The music stream should work forever.
📜 Log
events.js:305
throw err; // Unhandled 'error' event
^
Error [ERR_UNHANDLED_ERROR]: Unhandled error. (ErrorEvent {
target: WebSocket {
_events: [Object: null prototype] {
open: [Function],
message: [Function],
close: [Function],
error: [Function]
},
_eventsCount: 4,
_maxListeners: undefined,
_binaryType: 'nodebuffer',
_closeCode: 1006,
_closeFrameReceived: false,
_closeFrameSent: false,
_closeMessage: '',
_closeTimer: null,
_extensions: {},
_protocol: '',
_readyState: 2,
_receiver: null,
_sender: null,
_socket: null,
_bufferedAmount: 0,
_isServer: false,
_redirects: 0,
_url: 'wss://santiago3716.discord.media/?v=4&encoding=json',
_req: ClientRequest {
_events: [Object: null prototype],
_eventsCount: 4,
_maxListeners: undefined,
outputData: [],
outputSize: 0,
writable: true,
_last: true,
chunkedEncoding: false,
shouldKeepAlive: true,
_defaultKeepAlive: true,
useChunkedEncodingByDefault: false,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: 0,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
socket: [TLSSocket],
connection: [TLSSocket],
_header: 'GET /?v=4&encoding=json HTTP/1.1\r\n' +
'Sec-WebSocket-Version: 13\r\n' +
'Sec-WebSocket-Key: 3nWEHNgLf/4ol2wIoJ/XAQ==\r\n' +
'Connection: Upgrade\r\n' +
'Upgrade: websocket\r\n' +
'Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits\r\n' +
'Host: santiago3716.discord.media\r\n' +
'\r\n',
_keepAliveTimeout: 0,
_onPendingData: [Function: noopPendingOutput],
agent: undefined,
socketPath: undefined,
method: 'GET',
insecureHTTPParser: undefined,
path: '/?v=4&encoding=json',
_ended: false,
res: null,
aborted: true,
timeoutCb: null,
upgradeOrConnect: false,
parser: [HTTPParser],
maxHeadersCount: null,
reusedSocket: false,
host: 'santiago3716.discord.media',
protocol: 'https:',
[Symbol(kCapture)]: false,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: [Object: null prototype]
},
[Symbol(kCapture)]: false
},
type: 'error',
message: 'WebSocket was closed before the connection was established',
error: Error: WebSocket was closed before the connection was established
at WebSocket.close (/opt/app/node_modules/ws/lib/websocket.js:269:14)
at VoiceWebSocket.reset (/opt/app/node_modules/discord.js/src/client/voice/networking/VoiceWebSocket.js:53:60)
at VoiceWebSocket.shutdown (/opt/app/node_modules/discord.js/src/client/voice/networking/VoiceWebSocket.js:44:10)
at VoiceConnection.connect (/opt/app/node_modules/discord.js/src/client/voice/VoiceConnection.js:412:42)
at VoiceConnection.reconnect (/opt/app/node_modules/discord.js/src/client/voice/VoiceConnection.js:344:10)
at VoiceConnection.setTokenAndEndpoint (/opt/app/node_modules/discord.js/src/client/voice/VoiceConnection.js:234:12)
at ClientVoiceManager.onVoiceServer (/opt/app/node_modules/discord.js/src/client/voice/ClientVoiceManager.js:47:32)
at Object.module.exports [as VOICE_SERVER_UPDATE] (/opt/app/node_modules/discord.js/src/client/websocket/handlers/VOICE_SERVER_UPDATE.js:5:16)
at WebSocketManager.handlePacket (/opt/app/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
at WebSocketShard.onPacket (/opt/app/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
})
at VoiceConnection.emit (events.js:303:17)
at VoiceWebSocket.<anonymous> (/opt/app/node_modules/discord.js/src/client/voice/VoiceConnection.js:422:32)
at VoiceWebSocket.emit (events.js:314:20)
at VoiceWebSocket.onError (/opt/app/node_modules/discord.js/src/client/voice/networking/VoiceWebSocket.js:160:10)
at WebSocket.onError (/opt/app/node_modules/ws/lib/event-target.js:140:16)
at WebSocket.emit (events.js:314:20)
at abortHandshake (/opt/app/node_modules/ws/lib/websocket.js:868:15)
at WebSocket.close (/opt/app/node_modules/ws/lib/websocket.js:269:14)
at VoiceWebSocket.reset (/opt/app/node_modules/discord.js/src/client/voice/networking/VoiceWebSocket.js:53:60)
at VoiceWebSocket.shutdown (/opt/app/node_modules/discord.js/src/client/voice/networking/VoiceWebSocket.js:44:10) {
code: 'ERR_UNHANDLED_ERROR',
context: ErrorEvent {
target: WebSocket {
_events: [Object: null prototype] {
open: [Function: onOpen] { _listener: [Function: bound onOpen] },
message: [Function: onMessage] { _listener: [Function: bound onMessage] },
close: [Function: onClose] { _listener: [Function: bound onClose] },
error: [Function: onError] { _listener: [Function: bound onError] }
},
_eventsCount: 4,
_maxListeners: undefined,
_binaryType: 'nodebuffer',
_closeCode: 1006,
_closeFrameReceived: false,
_closeFrameSent: false,
_closeMessage: '',
_closeTimer: null,
_extensions: {},
_protocol: '',
_readyState: 2,
_receiver: null,
_sender: null,
_socket: null,
_bufferedAmount: 0,
_isServer: false,
_redirects: 0,
_url: 'wss://santiago3716.discord.media/?v=4&encoding=json',
_req: ClientRequest {
_events: [Object: null prototype] {
error: [Function],
response: [Function],
upgrade: [Function],
abort: [Function: bound onceWrapper] {
listener: [Function: bound emitClose]
}
},
_eventsCount: 4,
_maxListeners: undefined,
outputData: [],
outputSize: 0,
writable: true,
_last: true,
chunkedEncoding: false,
shouldKeepAlive: true,
_defaultKeepAlive: true,
useChunkedEncodingByDefault: false,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: 0,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
socket: TLSSocket {
_tlsOptions: {
allowHalfOpen: undefined,
pipe: false,
secureContext: [SecureContext],
isServer: false,
requestCert: true,
rejectUnauthorized: true,
session: undefined,
ALPNProtocols: undefined,
requestOCSP: undefined,
enableTrace: undefined,
pskCallback: undefined
�
},
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
secureConnecting: false,
_SNICallback: null,
servername: 'santiago3716.discord.media',
alpnProtocol: false,
authorized: true,
authorizationError: null,
encrypted: true,
_events: [Object: null prototype] {
close: [Array],
end: [Array],
newListener: [Array],
secure: [Function: onConnectSecure],
error: [Function: socketErrorListener],
data: [Function: socketOnData],
drain: [Function: ondrain]
�
},
_eventsCount: 7,
connecting: false,
_hadError: false,
_parent: null,
_host: 'santiago3716.discord.media',
_readableState: ReadableState {
objectMode: false,
highWaterMark: 16384,
buffer: [BufferList],
length: 0,
pipes: null,
pipesCount: 0,
flowing: true,
ended: false,
endEmitted: false,
reading: true,
sync: false,
needReadable: true,
emittedReadable: false,
readableListening: false,
resumeScheduled: false,
emitClose: false,
autoDestroy: false,
destroyed: true,
defaultEncoding: 'utf8',
awaitDrainWriters: null,
multiAwaitDrain: false,
readingMore: false,
decoder: null,
encoding: null,
[Symbol(kPaused)]: false
�
},
readable: false,
_maxListeners: undefined,
_writableState: WritableState {
objectMode: false,
highWaterMark: 16384,
finalCalled: false,
needDrain: false,
ending: false,
ended: false,
finished: false,
destroyed: true,
decodeStrings: false,
defaultEncoding: 'utf8',
length: 0,
writing: false,
corked: 0,
sync: false,
bufferProcessing: false,
onwrite: [Function: bound onwrite],
writecb: null,
writelen: 0,
afterWriteTickInfo: null,
bufferedRequest: null,
lastBufferedRequest: null,
pendingcb: 0,
prefinished: false,
errorEmitted: false,
emitClose: false,
autoDestroy: false,
bufferedRequestCount: 0,
corkedRequestsFree: [Object]
�
},
writable: false,
allowHalfOpen: false,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: undefined,
_server: null,
ssl: null,
_requestCert: true,
_rejectUnauthorized: true,
parser: HTTPParser {
'0': [Function: parserOnHeaders],
'1': [Function: parserOnHeadersComplete],
'2': [Function: parserOnBody],
'3': [Function: parserOnMessageComplete],
'4': null,
'5': null,
_headers: [],
_url: '',
socket: [Circular],
incoming: null,
outgoing: [Circular],
maxHeaderPairs: 2000,
_consumed: false,
onIncoming: [Function: parserOnIncomingClient],
[Symbol(resource_symbol)]: [HTTPClientAsyncResource]
�
},
_httpMessage: [Circular],
[Symbol(res)]: TLSWrap {
_parent: [TCP],
_parentWrap: undefined,
_secureContext: [SecureContext],
reading: true,
onkeylog: [Function: onkeylog],
onhandshakestart: [Function: noop],
onhandshakedone: [Function],
onocspresponse: [Function: onocspresponse],
onnewsession: [Function: onnewsessionclient],
onerror: [Function: onerror],
[Symbol(owner_symbol)]: [Circular]
�
},
[Symbol(verified)]: true,
[Symbol(pendingSession)]: null,
[Symbol(asyncId)]: 4543243,
[Symbol(kHandle)]: null,
[Symbol(kSetNoDelay)]: false,
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(timeout)]: null,
[Symbol(kBuffer)]: null,
[Symbol(kBufferCb)]: null,
[Symbol(kBufferGen)]: null,
[Symbol(kCapture)]: false,
[Symbol(kBytesRead)]: 0,
[Symbol(kBytesWritten)]: 253,
[Symbol(connect-options)]: {
rejectUnauthorized: true,
ciphers: 'TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA256:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!SRP:!CAMELLIA',
checkServerIdentity: [Function: checkServerIdentity],
minDHSize: 1024,
protocolVersion: 13,
maxPayload: 104857600,
perMessageDeflate: true,
followRedirects: false,
maxRedirects: 10,
createConnection: [Function: tlsConnect],
socketPath: undefined,
hostname: undefined,
protocol: undefined,
timeout: undefined,
method: undefined,
host: 'santiago3716.discord.media',
path: undefined,
port: 443,
defaultPort: 443,
headers: [Object],
_defaultAgent: [Agent],
servername: 'santiago3716.discord.media',
singleUse: true
}
},
connection: TLSSocket {
_tlsOptions: {
allowHalfOpen: undefined,
pipe: false,
secureContext: [SecureContext],
isServer: false,
requestCert: true,
rejectUnauthorized: true,
session: undefined,
ALPNProtocols: undefined,
requestOCSP: undefined,
enableTrace: undefined,
pskCallback: undefined
�
},
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
secureConnecting: false,
_SNICallback: null,
servername: 'santiago3716.discord.media',
alpnProtocol: false,
authorized: true,
authorizationError: null,
encrypted: true,
_events: [Object: null prototype] {
close: [Array],
end: [Array],
newListener: [Array],
secure: [Function: onConnectSecure],
error: [Function: socketErrorListener],
data: [Function: socketOnData],
drain: [Function: ondrain]
�
},
_eventsCount: 7,
connecting: false,
_hadError: false,
_parent: null,
_host: 'santiago3716.discord.media',
_readableState: ReadableState {
objectMode: false,
highWaterMark: 16384,
buffer: [BufferList],
length: 0,
pipes: null,
pipesCount: 0,
flowing: true,
ended: false,
endEmitted: false,
reading: true,
sync: false,
needReadable: true,
emittedReadable: false,
readableListening: false,
resumeScheduled: false,
emitClose: false,
autoDestroy: false,
destroyed: true,
defaultEncoding: 'utf8',
awaitDrainWriters: null,
multiAwaitDrain: false,
readingMore: false,
decoder: null,
encoding: null,
[Symbol(kPaused)]: false
�
},
readable: false,
_maxListeners: undefined,
_writableState: WritableState {
objectMode: false,
highWaterMark: 16384,
finalCalled: false,
needDrain: false,
ending: false,
ended: false,
finished: false,
destroyed: true,
decodeStrings: false,
defaultEncoding: 'utf8',
length: 0,
writing: false,
corked: 0,
sync: false,
bufferProcessing: false,
onwrite: [Function: bound onwrite],
writecb: null,
writelen: 0,
afterWriteTickInfo: null,
bufferedRequest: null,
lastBufferedRequest: null,
pendingcb: 0,
prefinished: false,
errorEmitted: false,
emitClose: false,
autoDestroy: false,
bufferedRequestCount: 0,
corkedRequestsFree: [Object]
�
},
writable: false,
allowHalfOpen: false,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: undefined,
_server: null,
ssl: null,
_requestCert: true,
_rejectUnauthorized: true,
parser: HTTPParser {
'0': [Function: parserOnHeaders],
'1': [Function: parserOnHeadersComplete],
'2': [Function: parserOnBody],
'3': [Function: parserOnMessageComplete],
'4': null,
'5': null,
_headers: [],
_url: '',
socket: [Circular],
incoming: null,
outgoing: [Circular],
maxHeaderPairs: 2000,
_consumed: false,
onIncoming: [Function: parserOnIncomingClient],
[Symbol(resource_symbol)]: [HTTPClientAsyncResource]
�
},
_httpMessage: [Circular],
[Symbol(res)]: TLSWrap {
_parent: [TCP],
_parentWrap: undefined,
_secureContext: [SecureContext],
reading: true,
onkeylog: [Function: onkeylog],
onhandshakestart: [Function: noop],
onhandshakedone: [Function],
onocspresponse: [Function: onocspresponse],
onnewsession: [Function: onnewsessionclient],
onerror: [Function: onerror],
[Symbol(owner_symbol)]: [Circular]
�
},
[Symbol(verified)]: true,
[Symbol(pendingSession)]: null,
[Symbol(asyncId)]: 4543243,
[Symbol(kHandle)]: null,
[Symbol(kSetNoDelay)]: false,
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(timeout)]: null,
[Symbol(kBuffer)]: null,
[Symbol(kBufferCb)]: null,
[Symbol(kBufferGen)]: null,
[Symbol(kCapture)]: false,
[Symbol(kBytesRead)]: 0,
[Symbol(kBytesWritten)]: 253,
[Symbol(connect-options)]: {
rejectUnauthorized: true,
ciphers: 'TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA256:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!SRP:!CAMELLIA',
checkServerIdentity: [Function: checkServerIdentity],
minDHSize: 1024,
protocolVersion: 13,
maxPayload: 104857600,
perMessageDeflate: true,
followRedirects: false,
maxRedirects: 10,
createConnection: [Function: tlsConnect],
socketPath: undefined,
hostname: undefined,
protocol: undefined,
timeout: undefined,
method: undefined,
host: 'santiago3716.discord.media',
path: undefined,
port: 443,
defaultPort: 443,
headers: [Object],
_defaultAgent: [Agent],
servername: 'santiago3716.discord.media',
singleUse: true
}
},
_header: 'GET /?v=4&encoding=json HTTP/1.1\r\n' +
'Sec-WebSocket-Version: 13\r\n' +
'Sec-WebSocket-Key: 3nWEHNgLf/4ol2wIoJ/XAQ==\r\n' +
'Connection: Upgrade\r\n' +
'Upgrade: websocket\r\n' +
'Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits\r\n' +
'Host: santiago3716.discord.media\r\n' +
'\r\n',
_keepAliveTimeout: 0,
_onPendingData: [Function: noopPendingOutput],
agent: undefined,
socketPath: undefined,
method: 'GET',
insecureHTTPParser: undefined,
path: '/?v=4&encoding=json',
_ended: false,
res: null,
aborted: true,
timeoutCb: null,
upgradeOrConnect: false,
parser: HTTPParser {
'0': [Function: parserOnHeaders],
'1': [Function: parserOnHeadersComplete],
'2': [Function: parserOnBody],
'3': [Function: parserOnMessageComplete],
'4': null,
'5': null,
_headers: [],
_url: '',
socket: TLSSocket {
_tlsOptions: [Object],
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
secureConnecting: false,
_SNICallback: null,
servername: 'santiago3716.discord.media',
alpnProtocol: false,
authorized: true,
authorizationError: null,
encrypted: true,
_events: [Object: null prototype],
_eventsCount: 7,
connecting: false,
_hadError: false,
_parent: null,
_host: 'santiago3716.discord.media',
_readableState: [ReadableState],
readable: false,
_maxListeners: undefined,
_writableState: [WritableState],
writable: false,
allowHalfOpen: false,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: undefined,
_server: null,
ssl: null,
_requestCert: true,
_rejectUnauthorized: true,
parser: [Circular],
_httpMessage: [Circular],
[Symbol(res)]: [TLSWrap],
[Symbol(verified)]: true,
[Symbol(pendingSession)]: null,
[Symbol(asyncId)]: 4543243,
[Symbol(kHandle)]: null,
[Symbol(kSetNoDelay)]: false,
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(timeout)]: null,
[Symbol(kBuffer)]: null,
[Symbol(kBufferCb)]: null,
[Symbol(kBufferGen)]: null,
[Symbol(kCapture)]: false,
[Symbol(kBytesRead)]: 0,
[Symbol(kBytesWritten)]: 253,
[Symbol(connect-options)]: [Object]
�
},
incoming: null,
outgoing: [Circular],
maxHeaderPairs: 2000,
_consumed: false,
onIncoming: [Function: parserOnIncomingClient],
[Symbol(resource_symbol)]: HTTPClientAsyncResource {
type: 'HTTPINCOMINGMESSAGE',
req: [Circular]
}
},
maxHeadersCount: null,
reusedSocket: false,
host: 'santiago3716.discord.media',
protocol: 'https:',
[Symbol(kCapture)]: false,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: [Object: null prototype] {
'sec-websocket-version': [ 'Sec-WebSocket-Version', 13 ],
'sec-websocket-key': [ 'Sec-WebSocket-Key', 'SNIPPED' ],
connection: [ 'Connection', 'Upgrade' ],
upgrade: [ 'Upgrade', 'websocket' ],
'sec-websocket-extensions': [
'Sec-WebSocket-Extensions',
'permessage-deflate; client_max_window_bits'
�
],
host: [ 'Host', 'santiago3716.discord.media' ]
�
}
},
[Symbol(kCapture)]: false
},
type: 'error',
message: 'WebSocket was closed before the connection was established',
error: Error: WebSocket was closed before the connection was established
at WebSocket.close (/opt/app/node_modules/ws/lib/websocket.js:269:14)
at VoiceWebSocket.reset (/opt/app/node_modules/discord.js/src/client/voice/networking/VoiceWebSocket.js:53:60)
at VoiceWebSocket.shutdown (/opt/app/node_modules/discord.js/src/client/voice/networking/VoiceWebSocket.js:44:10)
at VoiceConnection.connect (/opt/app/node_modules/discord.js/src/client/voice/VoiceConnection.js:412:42)
at VoiceConnection.reconnect (/opt/app/node_modules/discord.js/src/client/voice/VoiceConnection.js:344:10)
at VoiceConnection.setTokenAndEndpoint (/opt/app/node_modules/discord.js/src/client/voice/VoiceConnection.js:234:12)
at ClientVoiceManager.onVoiceServer (/opt/app/node_modules/discord.js/src/client/voice/ClientVoiceManager.js:47:32)
at Object.module.exports [as VOICE_SERVER_UPDATE] (/opt/app/node_modules/discord.js/src/client/websocket/handlers/VOICE_SERVER_UPDATE.js:5:16)
at WebSocketManager.handlePacket (/opt/app/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
at WebSocketShard.onPacket (/opt/app/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
}
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! discord-music-24-7@4.1.0 start: `node ./src/app.js`
npm ERR! Exit status 1
�
npm ERR! Failed at the discord-music-24-7@4.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-09-08T19_24_42_445Z-debug.log
📷 Screenshots
Paste a screenshot of the bug (if applicable).
❓ Other Information
- Node Version:
12.20.0