better handling of uri.getPort() = -1