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

Initialization fails #39

Closed
timvdalen opened this issue Jan 14, 2016 · 21 comments
Closed

Initialization fails #39

timvdalen opened this issue Jan 14, 2016 · 21 comments

Comments

@timvdalen
Copy link
Contributor

Every time I try to start, I get:

WARN init failed 404 undefined

Looking at the other project I know using this lib (yakyak/yakyak#111) I don't seem to be the only one.

@DanBUK
Copy link

DanBUK commented Jan 14, 2016

Yes getting the same issue here. It's 404'ing on https://talkgadget.google.com/u/0/talkgadget/_/chat

Been trying to figure out how that should change, but no luck so far.

@kyos0109
Copy link

I had same problem.
"2016-01-14 18:14:12 WARN init failed 404 Not Found" in console.

@juancarloscamargo
Copy link

Same here. It was working fine this morning. Stopped, restarted and the error showed up.

@lorenzos
Copy link
Contributor

I can confirm, I have issues with my bots since this morning. I'll try to take a look later.

@mhogerheijde
Copy link

https://github.com/tdryer/hangups still works, so they have the correct endpoint :)

@m0llysour
Copy link

The thing is that the init url that hangupsjs uses only appears as an origin for the channel url: https://github.com/tdryer/hangups/blob/08c6852ea65f1adca1841bb6d4e0adca288f2e52/hangups/channel.py#L30
This seem to be implemented in the same way in hangupsjs, so I can't find where the url is different in hangups (not js).

@mhogerheijde
Copy link

That URL is not used to do a call, it is used to signal the Auth API what the origin of the request is.

@mhogerheijde
Copy link

It seems that hangupsjs does the initialisation totally different,... it does a call and parses the HTML to get some properties out of a <script> tag. I see nothing resembling the same thing in hangups itself. They, however, need you to copy paste some url and the resulting key from authorisation. I don't know the reason for parsing the HTML, especially now that it is not possible to see what it contained.

@maxkrieger
Copy link

It seems like one potential new endpoint could be https://hangouts.google.com/webchat/u/0/frame or something similar. Am looking forward to hearing updates from this.

@DanBUK
Copy link

DanBUK commented Jan 14, 2016

So I've done a bit more digging into this.

I've MITM the chrome extension using a test account, and the following is the two requests I think we need to alter:

GET https://hangouts.google.com/webchat/extension-start
ResponseBody: ["h_exts","AMP3uWZLzq1xmKogAF7Zhekemyfu_ZdA26AAHFh_SEH19olHL9jmkxKPib5EyIyENKslpLehZ9-a",[] ]

This gives us the "pvt" value for the below:

GET https://hangouts.google.com/webchat/u/0/load?
client=sm&
prop=aChromeExtension&
nav=true&
fid=gtn-roster-iframe-id&
os=Linux%20x86_64&
stime=1452813562809&
xpc=%7B%22cn%22%3A%22gvtgg%22%2C%22tp%22%3A1%2C%22ifrid%22%3A%22gtn-roster-iframe-id%22%2C%22pu%22%3A%22https%3A%2F%2Fhangouts.google.com%2Fwebchat%2Fu%2F0%2F%22%7D&
ec=%5B%22ci%3Aec%22%2Ctrue%2Ctrue%2Cfalse%5D&
pvt=AMP3uWZLzq1xmKogAF7Zhekemyfu_ZdA26AAHFh_SEH19olHL9jmkxKPib5EyIyENKslpLehZ9-a&
href=chrome-extension%3A%2F%2Fnckgahadagoaajjgafhacjanaoiihapd%2Fdatachannel.html%3Frel%3D1&
pos=l&
uiv=2&
hl=en_GB&
hpc=true&
hsm=true&
hrc=true&
pop=true&
pal=1&
uqp=true&
sl=false&
mmoleh=36&
two=chrome-extension%3A%2F%2Fnckgahadagoaajjgafhacjanaoiihapd&
host=1&
zx=yqosawc8m1fk

ResponseBody:

<script>var AF_initDataKeys = ["ds:0","ds:1","ds:2","ds:3","ds:4","ds:5","ds:6","ds:7","ds:8","ds:9","ds:10","ds:11","ds:12","ds:13","ds:14","ds:15","ds:16","ds:17","ds:18","ds:19","ds:20","ds:21","ds:22","ds:23","ds:24","ds:25","ds:26","ds:27","ds:28","ds:29","ds:30","ds:31","ds:32","ds:33","ds:34","ds:35","ds:36","ds:37","ds:38"] ; var AF_dataServiceRequests = {'ds:0' : {id: 5.143648E7 },'ds:1' : {id: 5.1436482E7 },'ds:2' : {id: 5.1436483E7 },'ds:3' : {id: 5.1436484E7 },'ds:4' : {id: 5.1436485E7 },'ds:5' : {id: 5.1436486E7 },'ds:6' : {id: 5.1436487E7 },'ds:7' : {id: 5.1436488E7 },'ds:8' : {id: 5.1436489E7 },'ds:9' : {id: 5.143649E7 },'ds:10' : {id: 5.1436492E7 },'ds:11' : {id: 5.1436493E7 },'ds:12' : {id: 6.0996794E7 },'ds:13' : {id: 5.1436495E7 },'ds:14' : {id: 5.1436496E7 },'ds:15' : {id: 5.1436497E7 },'ds:16' : {id: 5.1436498E7 },'ds:17' : {id: 5.1436499E7 },'ds:18' : {id: 5.14365E7 },'ds:19' : {id: 6.1399017E7 },'ds:20' : {id: 6.1227348E7 },'ds:21' : {id: 5.1436501E7 },'ds:22' : {id: 5.1436502E7 },'ds:23' : {id: 5.1436503E7 },'ds:24' : {id: 1.07518388E8 },'ds:25' : {id: 5.1436504E7 },'ds:26' : {id: 5.1436505E7 },'ds:27' : {id: 5.1436506E7 },'ds:28' : {id: 5.1436507E7 },'ds:29' : {id: 5.1436508E7 },'ds:30' : {id: 5.1436511E7 },'ds:31' : {id: 5.143651E7 },'ds:32' : {id: 6.0995965E7 },'ds:33' : {id: 5.1436512E7 },'ds:34' : {id: 6.9103223E7 },'ds:35' : {id: 5.1436514E7 },'ds:36' : {id: 5.1436513E7 },'ds:37' : {id: 1.06074807E8 },'ds:38' : {id: 6.9103195E7 ,request:[] }}; var AF_initDataChunkQueue = []; var AF_initDataCallb... ... ....

This is I think what we called the INIT request. Just digging into this further and figuring out how many of the above params are really needed for the second request. (NB I broke up the GET params on the second request per line to make it a little more readable.)

@DanBUK
Copy link

DanBUK commented Jan 15, 2016

So using the URLs like I mentioned above, I am getting the same JS page loading in hangupsjs

In this gist i've been hacking on it, https://gist.github.com/DanBUK/70f7c23d1a8867da73af

But it seems to get to line 175 before failing. (I'm not really a coffeescript guy, hence hacking on the JS version)

@DanBUK
Copy link

DanBUK commented Jan 15, 2016

Ok so ref the above Gist, I did that, then commented out lines 176-199 so none of them entities were loaded, and things seem to be working.

I don't have a clean PR to make; I'de have to get my head around CoffeeScript for that... (Sorry I really havn't got my head thinking in a coffee script way...)

lib/channel:

lib/init:

CHAT_INIT_URL = 'https://hangouts.google.com/webchat/u/0/load';

//  stime=1452813562809&


  CHAT_INIT_PARAMS = {
    stime: 1452813562809,
    client: 'sm',
    nav: 'true',
    os: 'Linux',
    xpc: '{"cn":"gvtgg","tp":1,"ifrid":"gtn-roster-iframe-id","pu":"https://hangouts.google.com/webchat/u/0/"}',
    href: 'chrome-extension://nckgahadagoaajjgafhacjanaoiihapd/datachannel.html?rel=1',
    pos: 'l',
    uiv: '2',
    hl: 'en_GB',
    hpc: 'true',
    hsm: 'true',
    hrc: 'true',
    pop: 'true',
    pal: '1',
    uqp: 'true',
    sl: 'false',
    mmoleh: '36',
    host: '1',
    two: 'chrome-extension://nckgahadagoaajjgafhacjanaoiihapd',
    zx: 'yqosawc8m1fk',
    prop: 'aChromeExtension',
    fid: 'gtn-roster-iframe-id',
    ec: '["ci:ec",true,true,false]',
    pvt: null
  };

...
...

          entgroups = (function() {
            var i, results;
            results = [];
            //for (g = i = 1; i <= 5; g = ++i) {
            //  console.log(i);
            //  results.push(this.entities["group" + g].entities);
            //}
            return results;
          }).call(_this);
          //allents = map(concat.apply(null, [_this.entities.entities].concat(slice.call(entgroups))), function(e) {
          //  return e.entity;
          //});
          //safe = allents.filter(function(e) {
          //  var ref2;
          //  return e != null ? (ref2 = e.id) != null ? ref2.gaia_id : void 0 : void 0;
          //});
          //deduped = uniqfn(safe, function(e) {
          //  return e.id.gaia_id;
          //});
          return _this.entities = deduped;
        };
      })(this));
    };

Sorry this isn't a PR.

@tdryer
Copy link

tdryer commented Jan 15, 2016

It seems that hangupsjs does the initialisation totally different,... it does a call and parses the HTML to get some properties out of a <script> tag. I see nothing resembling the same thing in hangups itself. They, however, need you to copy paste some url and the resulting key from authorisation. I don't know the reason for parsing the HTML, especially now that it is not possible to see what it contained.

The request is used on startup to preload contact and conversation data. In hangups 0.3.0 I simplified the initialization process by removing this request, which coincidentally prevented the change Google made yesterday from breaking it.

An older fork of hangups was fixed by a small patch that could probably be easily adapted for hangupsjs.

@juancarloscamargo
Copy link

Applied changes proposed by DanBUK in one of my lab machines and it is working again.

@algesten
Copy link
Collaborator

thanks everyone for finding the problem/solution. i think what i'll do is make a patch release with @DanBUK fix. to proper follow @tdryer's original we would need a breaking change so that needs a major version increase, and i can't remember whether we used the init data stuff in yakyak.

@timvdalen
Copy link
Contributor Author

Cool! Is this the info that hangupsjs provides in the connected event or is it more low level than this?

@algesten
Copy link
Collaborator

@timvdalen as far as i can see the connected event doesn't actually send any data?!

https://github.com/algesten/hangupsjs/blob/v1.2.0/src/client.coffee#L98-L101

@algesten
Copy link
Collaborator

did i misunderstand. the entities are actually not available anymore :/ ... ok. perhaps it's major version after all...

@algesten
Copy link
Collaborator

fixed by @tmyt PR and released in 1.3.0. fix that follows @tdryer hangups to follow.

@timvdalen
Copy link
Contributor Author

@algesten Yeah you're right, I see I'm actually querying when I get that event.
As long as we still get the event :)

@algesten
Copy link
Collaborator

@timvdalen that will not change ;)

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

10 participants