Almost all cases this is a connection settings issue. Since you don't mention it, did you try the things I mentioned in the first entry in the thread you link? Specifically the first bullet.
Usually these issues are due to connection settings not being correct, so to first verify:
* Are you able to connect to the app manually using a header user (e.g. using modify headers plugin in firefox)? - (I see you did this, but as a reference to others)
* If you change the script to only be a timerdelay of maybe 10s (i.e. the user will connect to the app, wait 10s and disconnect) do you get any errors or will it connect when you execute it (i.e not "connect to app")?