Hotrian / OpenVRTwitchChat

Put your favorite Twitch Chat directly into any OpenVR game!
Other
173 stars 50 forks source link

Chat stops responding after a short while #24

Open Gigex opened 7 years ago

Gigex commented 7 years ago

I connect to the twitch chat and get the sound notification and see the messages , but after a while it just stops, no new messages coming in, and there's no indication of disconnecting or anything like that. If i disconnect and reconnect i can see messages again but only for a while till they stop coming in again.

running on HTC vive windows 7 tried it on audioshield and paranormal activity

Hotrian commented 7 years ago

Strange :o

I haven't worked on OVRTC in quite a while. I actually had dropped it, but picked it back up for a short time due to Twitch changing the API requirements, which I assume happened again, as I have used OVRTC in the past for several hours continuous on Windows 10 without it breaking, so I'm making the (possibly wrong) assumption that OVRTC is not directly at fault.

Anyone is free to tackle this issue and make a PR. I don't think I have the time right now to address any issues with OVRTC unless they are fatal issues (such as the API change which I believe completely broke OVRTC and prevented it from reading Twitch chat at all).

You may be able to help by posting your output_log.txt from inside the Data folder. There may be an obvious error popping up somewhere. The output_log.txt is cleared each time you restart the program, so you'll have to get the program to error out, then send a copy of that log before restarting the program.

Edit: I hope you guys don't think I'm a shitty dev for ignoring support issues on something I released. JSYK I'm pretty sure I've made $0 off the donate button for OVRTC :P. I'm actually a Steam dev now, and I'm just prioritizing paying customers. I hope you guys can understand. If it turns out to be a quick fix, of course I'll do what I can, but I don't have the time to do deep memory analysis right now :P. As I said, anyone is free to fork it, fix it, and PR <3.

Gigex commented 7 years ago

Hey, i'm just glad someone took the time to make something like this, i checked the error log and this error keeps repeating with different values in the "p" parameter:

Error on page (https://api.twitch.tv/kraken/channels/realgigex/follows?limit=100?p=10249362626587): 400 Bad Request(Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 37)

I don't expect you to fix it if it's too much trouble. If and when you get the time to check this out, i'd be most grateful. I am using the OpenVRDesktopDisplayPortal for now (but ofc its less slick than the twitch chat one)

aeonblack6 commented 6 years ago

I'm having this issue as well, any updates on what might be causing this/what the fix is?

You really should keep working on this @Hotrian as it's the only solution out there, as far as I can tell. If you can figure this problem and out for us, I would be happy to send a donation your way!

Hotrian commented 6 years ago

Based on that error code it looks like Twitch changed the API requirements again which is probably what broke it :(. I’ll try and hunt down what changed.

aeonblack6 commented 6 years ago

Awesome, thanks man!

Hotrian commented 6 years ago

So it would seem the API has definitely changed.

The exact error being returned is

{ "error": "Bad Request",
  "status": 400,
  "message": "strconv.Atoi: parsing \"100?p=45034142523096\": invalid syntax"}

Seems that Kraken either no longer likes the limit command, or is rejecting the URL anti-cache. The p parameter is simply being added so that we always get a fresh copy from Kraken, otherwise it seems the UnityEngine.WWW class will cache the result, so we cannot get an updated reply from Kraken.

This may be due to Twitch slowly moving away from Kraken towards Helix, or may be due to a simple update to Kraken that went unmentioned and unnoticed to most. We are only using the UnityEngine.WWW class because Unity is on a pretty messed up version of .NET right now, and doesn't have access to a lot of the classes we would otherwise use.

Edit: Although I'm not sure why this would cause the chat to break, I assume there are other API changes as well that are causing issues.

Hotrian commented 6 years ago

A simple fix seems to be to add a return url; under this line. Seems that the URL cache isn't an issue anymore. Perhaps it was actually Kraken who was replying with cached info, and not UnityEngine.WWW. Still testing to see if the chat breaks, but Followers and Viewer Count is working correctly with this simple change.

Edit: 20 minutes and still working.. When does it typically break?

Hotrian commented 6 years ago

So I just tested that fix for 2 hours and I only encountered the following error:

Error on page (https://api.twitch.tv/kraken/streams/<removed>): 502 Bad Gateway

This is somewhat normal for a URI as busy as Twitch, and otherwise the application still seems to be functioning fully. I am still receiving follower notifications as well as chat, and the view count still matches the count on the site.

I'll see about pushing this build.

Hotrian commented 6 years ago

The new build is over here. Would be great if you guys could test it out ♥.

I am prepared to discuss the audacity of the solution over here if need be.

Hotrian commented 6 years ago

Just finished running the 1.0.7.4-beta build for over 2.5 hours straight, and didn't run into a single issue. Hopefully that closes this issue.. for now :).

aeonblack6 commented 6 years ago

I am still having issues with the chat. The viewer count seems to be correct from what I can tell, but the chat itself is not updating. I'm getting the following line repeating:

Found 17 followers, retrieved top 17 (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 37)

And I confirmed that it's definitely not updating the chat.

Hotrian commented 6 years ago

Found 17 followers, retrieved top 17 (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 37)

This one is not an error, it's just how Unity outputs log data.

Does the chat work in the first place? You should get two Acknowledging Client Capabilities! followed by a Connected to {0}! if the IRC connects properly.

Hotrian commented 6 years ago

What channel are you trying to connect to, and are you doing so anonymously or with a User/OAUTH?

aeonblack6 commented 6 years ago

That makes sense, nothing else is showing up in the log for me though.

The chat definitely works upon initial connection and as for how long it takes to break, it's tough to say, but it's not that long. Maybe 20-30 minutes?

I am getting both "Acknowledging Client Capabilities!" commands as well as the "Connected To aeonblack6" command. I'm connecting as myself to my own twitch channel using my own User/OAUTH code.

Hotrian commented 6 years ago

That's strange~ You shouldn't be having issues, but IIRC Twitch would sometimes disconnect me randomly during early testing. (I think I was failing to respond to PING messages back then, but I could be mistaken)

Could you please try this build temporarily (if GitHub lets you download that one)? This one is a bit more verbose, as the log should include the entire IRC log. Once you've been disconnected please post that log ♥. Specifically the last few IRC messages might be significant.

The source isn't public, but it just does a Debug.Log(message); on this line, so anything piped through should be logged.

A simple fix may be to check for disconnection and reconnect when Twitch drops us. I'm usually able to run for several hours without being disconnected, but it's possible a less stable internet causes the IRC to drop.

aeonblack6 commented 6 years ago

Can't download that link, GitHub isn't letting me.

Hotrian commented 6 years ago

Dang, thought that might happen. It was a draft release :P. Please try this link.

aeonblack6 commented 6 years ago

Okay, so I downloaded that and I had my moderator join me in channel for about 25 minutes. I was streaming in the exact same way, had the game loaded in, everything (to ensure we didn't miss anything), and the chat and viewer count both seemed to work correctly the entire time. Chat didn't drop out, nothing. So, in the meantime, I can definitely run the build you just linked me, but there is clearly something else besides the logging going on between the two versions. Regardless, I've attached the log here. When I stream for a longer period tomorrow I'll run this version again and if it drops out I will at least have a detailed log of it.

output_log3.txt

aeonblack6 commented 6 years ago

Well, this is really strange. It definitely still crashes using that client, but there is literally nothing in the logs that mentions it. It ran for quite a while in that build, probably an hour or so.

The only thing of note in the logs is that around the time it lost connection with the chat, there was a ping.

PING :tmi.twitch.tv

You can see near the end of the log, I disconnected and reconnected manually, but other than that, the logs are pretty standard. The last line of chat I got was:

:bawhee!bawhee@bawhee.tmi.twitch.tv PRIVMSG #aeonblack6 :this guard is probably a traitor.

output_log4.txt

Hotrian commented 6 years ago

Thanks! Looks like it wasn't a failed PING<->PONG that caused the disconnect. You got the PING, presumably Twitch received the PONG, and then ~30 seconds later you got one last message from the server. It is possible that Twitch never got the PONG so they dropped you, or that your connection to Twitch dropped enough packets that it triggered the disconnect.

I'll see about adding a simple timer that can restart the connection automatically if it drops.

aeonblack6 commented 6 years ago

Awesome! Thanks for all your work on this, it is really appreciated. OVRdrop is great, and you did some awesome work with that as well, and it works with a standard twitch chat window, but your overlay with this one gives me all the info i need in one place and means i don't need to have another window open and running.

DorCoMaNdO commented 4 years ago

@Hotrian I know the repo is inactive but I've been just browsing around since the program seems to be broken again by the new customizable emotes from the points system. Came across this unrelated issue, the reason the API request here failed is because of a bad parameter, ?limit=100?p=... where it should be ?limit=100&p=... (replace ? with & in TwitchChatTester.cs line 238)

Hotrian commented 4 years ago

@DorCoMaNdO Thanks, I hadn't noticed this issue previously.