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

Login connection failure / timeout #628

Closed
2 tasks done
vaeltis opened this issue Apr 7, 2019 · 11 comments
Closed
2 tasks done

Login connection failure / timeout #628

vaeltis opened this issue Apr 7, 2019 · 11 comments

Comments

@vaeltis
Copy link

vaeltis commented Apr 7, 2019

Bug report

  • I understand the difference between Streamlink and Streamlink Twitch GUI.
  • This is a bug report and I have read the contribution guidelines.

Environment details

Operating system and version:
Windows 10

Streamlink Twitch GUI version:
Streamlink Twitch GUI Version 1.7.0

Streamlink version:
Streamlink Version 1.1.1

Configuration details:
Default

Description

I recently updated my Streamlink Twitch GUI and streamlink to the newest version as it had notified me that there was a newer version, in doing so I had to log back into my Twitch account again, However getting to the Authorization page, and trying to authorize, the page is in a loading sequence for a few seconds and then is forwarded to a connection interruption/error page. I don't know if it's a Twitch API issue or because I updated to the latest version.

Expected / Actual behavior

Twitch to properly authorize and give Streamlink access to my account, and allowing me to properly view streams and everything else that it has to offer once connected.

Reproduction steps

  1. ...Click to Person silhouette in the Twitch GUI.
  2. ...Click Sign In and be forwarded to a Twitch Authorization page on your default browser(Firefox in my case, didn't work with Chrome either)
  3. ...Hit Authorize on the page, let it load and hopefully give authorization access, or instead get a connection interruption/error

Log output


Additional comments, screenshots, etc.

Before Clicking Authorize. https://i.imgur.com/qYoyVUf.png

About 10 seconds after Clicking Authorize. link removed

Not logged in on streamlink and am only presented with the Abort Button. https://i.imgur.com/QKhtVLf.png

@bastimeyer
Copy link
Member

bastimeyer commented Apr 7, 2019

Streamlink Twitch GUI has to start a local webserver in order to receive the access token from Twitch in your web browser. You can see on the auth page on Twitch where it will redirect you, namely http://localhost:65432/redirect. If you have blocked the local webserver from being started, it can't redirect you and you will get a timeout error.

Make sure that you are not blocking the web server via an external application (firewall, antivirus, etc).

If you can't do that, take a look at the URL of the redirection. It includes the access token which you can simply copy and paste into the Twitch GUI's access token field (you've already enabled advanced settings).

But before doing this
You should delete the screenshots from imgur and unregister Streamlink Twitch GUI from your Twitch account's app connections list. Your second screenshot (which I've removed from your post) includes your own private access token in the URL bar, which means that everyone can now login into your account. By unregistering the app and then re-authing it, the old access token gets invalidated.

@Phoscur
Copy link

Phoscur commented Apr 7, 2019

Having the same issue after windows 10 reinstall today, using the tipps in https://github.com/streamlink/streamlink-twitch-gui/wiki/Twitch.tv-login I was able to use the advanced settings, then copying the accesstoken from the localhost url (between access_token=&) and pasting that into the alternative login, so I was still able to login.

Weirdly I could confirm the Twitch-Login working on an older computer with an old livestreamer version works as expected.

@Primeey
Copy link

Primeey commented Apr 7, 2019

I'm also having problems. I kept getting a localhost refused to connect error when I clicked Authorize. Nothing was blocking the webserver. Thankfully doing it manually by copying the access token from the localhost url and pasting it into Streamlink Twitch GUI worked just fine.

@bastimeyer
Copy link
Member

Nothing has changed this release in regards to the auth system.
What could be causing problems on your systems is the new executable. As I've said, please make sure that it's not blocked by any firewall rules, etc.

@vaeltis
Copy link
Author

vaeltis commented Apr 7, 2019

I'm able to login through the access token but not by normal means, I've checked my firewall and antivirus and everything is fine and is allowed through but still having issues with connecting to the local webserver, I'll have to dive more into it and see what else could be the issue another time when I'm more free, but for now I'll just use the access token to get around the issue.

@Nepturian
Copy link

Nepturian commented Apr 8, 2019

To work around this bug/issue, install v1.6.0 login to your account, and then install v1.7.0.
This solved the problem for me, until developer fixed the authentication problem!

@bastimeyer
Copy link
Member

bastimeyer commented Apr 8, 2019

👇 👇 👇 👇 👇

Looks like there's a NodeJS bug here, but only on Windows.

I will see whether I can fix this, but I'm not sure yet. In the mean time, please just copy the access_token value from the return URL of your web browser and paste it into the access token field on the Twitch GUI's login page after enabling advanced settings in the main settings menu.
https://github.com/streamlink/streamlink-twitch-gui/wiki/Twitch.tv-login

👆 👆 👆 👆 👆


To give you a more detailed explanation, something seems to be wrong with Node's net.Socket implementation on Windows. It could also be a bug in NW.js, in case they are applying customizations here, I don't know.

When writing data to a http.ServerResponse via write() or end()
https://github.com/streamlink/streamlink-twitch-gui/blob/v1.7.0/src/app/services/auth.js#L87
it'll try to call this.connection.cork() first, but this method doesn't seem to exist on Windows here. The http.ServerResponse class is supposed to inherit from net.Socket -> stream.Duplex -> stream.Writable (which it actually does) and therefore have this method on its prototype.

As I've said earlier, the Twitch GUI's auth stuff hasn't been touched in a while and the only thing that happened in this release related to that was a NW.js version bump from 0.26.6 to 0.37.2 (Node 9.1.0 to 11.13.0), but the specific Node APIs haven't been changed either.

This is weird. I will have to dig a bit deeper when I get the time.

@bastimeyer bastimeyer changed the title Login connection failure with Streamlink Login connection failure / timeout Apr 8, 2019
@bastimeyer bastimeyer pinned this issue Apr 8, 2019
@bastimeyer
Copy link
Member

bastimeyer commented Apr 10, 2019

Ok, so I did some more debugging, and it's weird...
As I've mentioned above, the culprit here is the missing stream.Duplex.prototype.cork method.

The stream.Duplex class inherits its prototype from stream.Readable. All properties from stream.Writable (including cork) also get copied onto that prototype object for having a multiple inheritance structure:
https://github.com/nwjs/node/blob/4ff08046bd599752239b2d61428024a82734d0cf/lib/_stream_duplex.js#L35-L52

What is going wrong here is that for some very weird reason, the copying of the properties from the stream.Writable prototype is not happening. This issue does only occur on Windows and also only when the application code gets loaded, but not always, sometimes it works like it's supposed to. This can be checked in the dev tools by executing

Object.prototype.hasOwnProperty.call( require("stream").Duplex.prototype, "cork" );

Neither the application code nor its (runtime) dependencies alter the functionality of any of Node's native modules. This makes me believe that this is some kind of optimization issue of the v8 JS engine. I would really like to know what exactly is going on here.

I've found a workaround for now, though. If the stream and net Node modules get loaded first by NW.js before loading the application code, the stream.Duplex.prototype object will have all of its methods correctly applied. I'm not sure though if I'm happy with this kind of workaround. I will wait a bit and see if I can find a proper solution.

@siint
Copy link

siint commented Apr 10, 2019

Could my problem (issue 619, oauth token not saving) be somehow connected to this problem?
My Twitch GUI is able to save its config files in the default location but the token is still not saving.

@bastimeyer
Copy link
Member

@siint No, what you have described in your issue is not related to that. Unfortunately, all I can tell you is to make sure that NW.js is able to write to the config directory. If you're unable to solve this, please try to get a full NW.js/Chromium debug log and post it in the other thread, as this discussion doesn't belong here.

@bastimeyer
Copy link
Member

New release with the included workaround:
https://github.com/streamlink/streamlink-twitch-gui/releases/latest

I'll leave this thread open for a bit though...

@bastimeyer bastimeyer unpinned this issue Apr 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants