Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot connect to channel? #35

Closed
glitchto opened this issue Jun 24, 2018 · 14 comments
Closed

Cannot connect to channel? #35

glitchto opened this issue Jun 24, 2018 · 14 comments

Comments

@glitchto
Copy link

"BadStateExeption: Must be connected to at least one channel." at event, even with provided client class, correct initialization, non capitalized channel names, double checked keys.

@swiftyspiffy
Copy link
Member

Can you share your code?

@glitchto
Copy link
Author

glitchto commented Jun 24, 2018

I first followed the tutorial by HonestDanGames you linked, after I used your class "Chat Client for Unity"
which by the way has these variables missing "Args" from their name's end:
TwitchLib.Client.Events.OnJoinedChannel
TwitchLib.Client.Events.OnChatCommandReceived
... have passed correct params:

public class TwitchCL : MonoBehaviour
{
    private Client _client;
    private string channelName = "mychannel"; //privacy
    private string botName = "mychannelbot";
    void Start()
    {
        //Set to run in minimized mode
        Application.runInBackground = true;
        //Create Credentials instance
        ConnectionCredentials credentials = new ConnectionCredentials(botName, Secrets.botAccessToken);
        //Create new instance of Chat Client
        _client = new Client();
        _client.Initialize(credentials, channelName);
        _client.OnMessageReceived += _client_OnMessageReceived; ;
        _client.Connect();
    }

Edits: sorry, I'm not familiar with this code insert

@swiftyspiffy
Copy link
Member

That code looks like it’d work in the normal (not unity) library. You might also try listening to OnConnected, OnJoinedChannel, and OnSendReceiveData events. The latter will fire every time a piece of data is received from Twitch, and is great for debugging problems.

Other than that, you’ll probably have to wait for Lucky to respond

@RRickkert
Copy link
Member

RRickkert commented Jun 24, 2018

Could you provide your Unity version? As of Unity 2018 the TwitchClient is no longer functional. See: https://fogbugz.unity3d.com/default.asp?1045497_7ifkb9kvjpn7113n This might also be the case for some later versions of Unity 2017. This bug report is specifically for WebSocket4Net, however, TwitchLib's client uses that in the background, so it won't work.

I created a Unity package which you an import into any empty unity project, press play, and it should show "opened" in the log. If it doesn't that means your Unity version won't work with TwitchLib's Client: https://cdn.discordapp.com/attachments/415976614954795018/458754439793213453/WebSocket4Net_Unity_TestPackage.unitypackage

@glitchto
Copy link
Author

Hello, I do have the latest Unity installed, yes. Your package link is dead for me.
Should I revert Unity and for what version? Or is there another way?
Thank you.

@RRickkert
Copy link
Member

I just noticed it didn't work, trying to fix it D:

@RRickkert
Copy link
Member

Can you try to just copy paste the link instead? It works here. Github doesn't like links for whatever reason?
If you indeed have the latest version, you'll have to revert to an older version sadly..

@glitchto
Copy link
Author

What exact version would you recommend?

@glitchto
Copy link
Author

Would you recommend other API that works without uninstalling Unity?

@RRickkert
Copy link
Member

From the official releases, I can confirm working:

  • Unity 2017.4.6f1 (LTS)
  • Unity 2017.3.1f1

From the beta releases, I can confirm working:

  • Unity 2018.2.0b1

From the official releases, I can confirm broken:

  • Unity 2018.1.6f1
  • Unity 2018.1.5f1

From the official releases, I can confirm broken:

  • Unity 2018.2.0b4 - Unity 2018.2.0b9

So personally I would recommend the latest version of Unity 2017 for now, which has LTS (long term support).

I can also recommend installing the Unity Hub, to easily manage your Unity versions, so it makes it easier to have multiple versions installed, and switching between them is much easier.

As for any other API. the TwitchLib.API module should work just fine. It's just the TwitchLib.Client which is broken.
For any other Twitch chat bot client, I don't know any.

@glitchto
Copy link
Author

Thanks, I do have Unity Hub, see if 2017.4.6f1 (LTS) does it.

@glitchto
Copy link
Author

Installed, works like charm. Thank you !

@RRickkert
Copy link
Member

See issue #36 for more information

@swiftyspiffy
Copy link
Member

Will go ahead and close this. Feel free to reopen as necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants