api icon indicating copy to clipboard operation
api copied to clipboard

Issue with connecting via twitch.js

Open coolcalcacol opened this issue 5 years ago • 8 comments

Describe the bug Using twitch.js, I get no output from the irc server except a Disconnected unexpectedly error.

To Reproduce Steps to reproduce the behavior:

const ChatClient = require('twitch-chat-client');
const client = ChatClient.anonymous({
	hostName: 'irc.fdgt.dev',
})
client.connect();

client.onJoin((channel, user) => {
    console.log("Connected");
})

client.onCommunitySub((channel, user, subInfo, msg) => {
    console.log(`${channel}, ${user}, onCommunitySub`);
})

client.onSub((channel, user, subInfo, msg) => {
    console.log(`${channel}, ${user}, onSub`);
})

client.say('#channel', 'submysterygift.tier3 --giftcount 10');
client.say('#channel', 'subscription --tier 3');

Expected behavior Using the above code, I expect 10 gifted sub events and one tier three regular subscription

coolcalcacol avatar Jul 06 '20 23:07 coolcalcacol

Hi, its probably related: I cannot connect with tmi.js either.

This code outputs: Unable to connect.

const tmi = require("tmi.js");

const client = new tmi.Client({
  connection: {
    server: "irc.fdgt.dev",
  },
});

client
  .connect()
  .then(() => {
    console.log("connected");
  })
  .catch((err) => {
    console.error(err);
  });

thomaslule avatar Jul 08 '20 08:07 thomaslule

@thomaslule If you’re using tmi on the server-side, you’ll need to add secure: true to your connection config.

const client = new tmi.Client({
  connection: {
    secure: true,
    server: "irc.fdgt.dev",
  },
});

That’s a failing of the docs that will be addressed by fdgt-apis/website#27.

trezy avatar Jul 08 '20 23:07 trezy

@trezy oh thanks that's right, sorry for the noise in this issue

thomaslule avatar Jul 10 '20 06:07 thomaslule

@coolcalcacol I still haven't had a chance to actually verify this bug, but I've got a suspicion that you may need to set the ssl option to true when creating the connection. For example:

const client = ChatClient.anonymous({
  ssl: true,
  hostName: 'irc.fdgt.dev',
})

Let me know whether or not that solves the issue. If so, I'll update the docs.

trezy avatar Jul 15 '20 06:07 trezy

ssl is the default... at least it should be.

d-fischer avatar Jul 15 '20 12:07 d-fischer

@d-fischer It is for Twitch, but not for custom servers you have to explicitly mark it secure. I believe it's like that for people running local IRC servers

opti21 avatar Jul 25 '20 20:07 opti21

Where'd you get that idea? I know the opposite is true from being the author of the library.

d-fischer avatar Jul 25 '20 21:07 d-fischer

Suggested fix didn't work, apologies for the delay

coolcalcacol avatar Sep 02 '20 21:09 coolcalcacol