Added an optional uri parameter to take the pace of host and port.