tmijs / tmi.js

šŸ’¬ Javascript library for the Twitch Messaging Interface. (Twitch.tv)
https://tmijs.com
MIT License
1.55k stars 214 forks source link

Can't connect: cannot create property 'type' on string 'reserved fields must be empty' #318

Closed devolution2409 closed 5 years ago

devolution2409 commented 5 years ago

Actual behaviour: Can't login on twich irc chat

Expected behaviour: To be able to log in

Error log:

[15:06] info: Connecting to irc-ws.chat.twitch.tv on port 80..
[15:06] info: Sending authentication to server..
/opt/app/node_modules/tmi.js/node_modules/ws/lib/WebSocket.js:426
    event.type = 'error';
               ^

TypeError: Cannot create property 'type' on string 'reserved fields must be empty'
    at WebSocket.onError (/opt/app/node_modules/tmi.js/node_modules/ws/lib/WebSocket.js:426:16)
    at emitTwo (events.js:126:13)
    at WebSocket.emit (events.js:214:7)
    at Receiver.onerror (/opt/app/node_modules/tmi.js/node_modules/ws/lib/WebSocket.js:851:10)
    at Receiver.error (/opt/app/node_modules/tmi.js/node_modules/ws/lib/Receiver.js:321:8)
    at Receiver.processPacket (/opt/app/node_modules/tmi.js/node_modules/ws/lib/Receiver.js:195:12)
    at Receiver.add (/opt/app/node_modules/tmi.js/node_modules/ws/lib/Receiver.js:95:24)
    at realHandler (/opt/app/node_modules/tmi.js/node_modules/ws/lib/WebSocket.js:800:20)
    at firstHandler (/opt/app/node_modules/tmi.js/node_modules/ws/lib/WebSocket.js:790:7)
    at _combinedTickCallback (internal/process/next_tick.js:132:7)

Server configuration

I kinda think the error is related to the websocket component of tmi, namely ws, it seems that npm pull an old version, that doesn't work as of today.

I tried swapping the websocket npm install by the latest version of ws.

The error is then gone, however, i can't never connect even tho my username and OAUTH token are good.

MrDrummer commented 5 years ago

I am only just starting to get the same thing. Works on CentOS, does not work on Windows 10.

Note that just before the error, I get a console log: error: Could not connect to server. Reconnecting in 2 seconds...

I get the same TypeError that devolution gets.

EDIT: Turns out it was my work's network blocking the connection.

devolution2409 commented 5 years ago

@MrDrummer Glad it works for you, never worked for me again after that so i switched to twich-js

AlcaDesign commented 5 years ago

Could anyone make a quick test using tmi.js@1.3.x? (And/or possibly with the current repo? (1.4))

From NPM: (1.3)

$ npm install tmi.js@1.3

or from Github: (upcoming 1.4)

$ npm install tmijs/tmi.js#1a55b00

I haven't been able to replicate this error myself, but here's a quick base that you can copy-paste if it'll help. šŸ™

const tmi = require('tmi.js');
let client = new tmi.Client({
    options: { debug: true },
    identity: {
        username: '',
        password: ''
    }
});
client.connect();