Tuesday, October 21, 2008

Tata Wimax keepalive

My tata wimax connection works well most of the time but it has a supremely annoying feature that to get connected, one is redirected to login in their login site (pretty much how the internet connection works in many hotels). If you are idle for sometime, it will auto logoff. Since my internet connection is not so fast, I usually download over the night and open a keepalive window.

This worked well up until a couple of months back. Now they seem to have decided to disconnect users at random times regardless of internet activity. Not to be deterred by the challenge, I started thinking of how to work around this. The login screen looks like this:



I needed something that keeps logging me in automatically. Qt/WebKit was the obvious choice. It would have been trivial had the post URL of the above form not been dynamic (i.e it has a magic session number in the POST url).

So, here's what I had to do:
1. Keep loading some website at periodic intervals. Check if I get redirected to their login page. It was a bit tricky to use Qt/WebKit to detect a redirect (in fact, there are two redirects); one has to resort to using timers and check if all the redirection has been done and the pages have been completely loaded.

2. Once the page is loaded I need to get the "dynamic" post URL of the form. I could do a grep in the html but that would be too simple :-) So, I tried evaluateJavaScript that will look in the DOM and return me the post url. Unfortunately, the QVariant returned by evaluateJavaScript() is always null. So, the next strategy was to fill the form details and submit the form entirely using JavaScript. And that worked like a charm :-)

You can find the git repo here (btw, Assembla rocks!).

It struck me later that I probably didn't need Qt WebKit at all. I think a html/js loading a website periodically in a separate frame and trying to logon if necessary could have worked as well.

11 comments:

pacodani said...

I dont understand why do you open a keepalive window if it is actually dowloading.

cheers!

Girish Ramakrishnan said...

pacodani : I mention the reason in my second paragraph "Now they seem to have decided to disconnect users at random times regardless of internet activity." So even if something is downloading, they just log me off.

Anonymous said...

I have a similar problem with my internet. I get it from my university across the road. Occasionally my wireless will drop out and I'll have to reconnect -- this means clicking activate again. Also, sometimes when I activate it will forget who I am and I will need to login again also.

Very annoying! Especially on my mobile phone when I have small browser and have to navigate to my keepalive tab, press activate and then login again with my crazy password they force us to have.

Anonymous said...

Well, actually I do not understand why you chose that way. You could have done exactly the same with a background deamon written in Python.

- Try to connect to a page every x seconds
- Parse the page to get the title
- If this is the login page, find the form POST URL
- Submit the form.
- Back on track...

Or am I missing something ?

pacodani said...

"Since my internet connection is not so fast, I usually download over the night and open a keepalive window.

This worked well up until a couple of months back. Now they seem to have decided to disconnect users at random times regardless of internet activity."

Sorry, I think it can be misunderstood...

Anonymous said...

I have a dead simple python script that does this, with a simple regex to get the magic string.

Anonymous said...

HAPPY NEWS FOR BANGALORE TECHIES AND SOFTWARE EMPLOYEES OF TOP CORPORATE COMPANIES.

THE TATA WIMAX HAS PLANNED SOME EXCLUSIVE OFFERS FOR THEM.

To know the details of offer applicaple for the company.

And to have New connection of Tata wimax connection. It is RECOMMENDED to Contact On SUNIL—- 9243198958

SUNIL —9243108958

Have a nice …….Day…….

Anonymous said...

Hmm, now if I could only find an iPhone app which would automatically log me into my wifi system..

Also: re: using QTWebKit -- sounds like a case of "when you only have a hammer, everything looks like a nail".

Anonymous said...

Personally, i dont like tata wireless or broadband.

Anonymous said...

Hi Wish You all Happy New Year For Bangalore Residents From Tata Communications.

We are planning to come with new plans for new year like 2 Mbps Unlimited,Night Unlimited Time based plans.Even we trieng to give 4Mbps connection also.Please Contact@ 9243108958.

For more Details And New Connection
Please contact Sunil On 9243108958.

Only For Bangalore Customers........
Have a Prosperous New Year......

Anonymous said...

Well only good feature that has come from TATA in broadband arena is their plug and surf USB for broadband...they can make it cheaper because there is a huge market out there for that device in the villages of our country//