Perphas its something to do with this line
url = new URL("https", rptUrl, 443, "/");
even when changed to
url = new URL("https", rptUrl, "/");
I got the same error. Doing all the steps in the example but still setting the URL like
URL url = new URL ( rptUrl );
Eric