I was also facing the same issue but I finally managed to solve it.
Try parameterizing the username/password and host: port in the web_set_user function.
what I was doing wrong was only parameterize the username /password but kept the host name hard coded.
The host name changed since the first time I recorded the script, my scripts were failing as I had hard coded host name in script.
Hope this tip helps.