Hi,
if the program work perfectly but error when using proxy, i'm sure this was due to different environmental factor. so, the problem is not the code, but your network (firewall, proxy configurations, etc).
If you OK, first I will check the code, and if everything is fine then allow me to access your server remotely.
cheers,
Amarzan