Hello Satish,
You need to have the firewall rules open in the proxy server based on how proxy set up. It is always a good idea to have the user id, password, host name, port in a separate properties file with appropriate security outside the code. That said the server A traffic should not be blocked in server B when it is trying to reach server C (I find telnet ipaddress port# a very useful command to check if traffic is allowed). Based on how the Server B is routing the traffic your IP address for ServerC could change (If there is a NAT involved). If that's the case then you will have to use the server C (NAT IP) to connect to the OnDemand server.
Thanks
Siva