“SocketException: Unconnected sockets not implemented” with self-signed SSL certificate

前端 未结 6 1132
轮回少年
轮回少年 2021-01-17 19:49

(I\'ve asked the same question of the jmeter-user mailing list, but I wanted to try here as well - so at the least I can update this with the answer once I find it).

6条回答
  •  北荒
    北荒 (楼主)
    2021-01-17 20:36

    Most javax.net.SocketFactory implementations define all createSocket() methods that have parameters as abstract. But have a createSocket() method without parameters that looks like this:

    public Socket createSocket() throws IOException {
       throw new SocketException("Unconnected sockets not implemented");
    }
    

    So if you subclass the abstract javax.net.SocketFactory you will be force to override the methods with parameter, but it's easy to miss to override the createSocket() method without parameters. Thus the exception is thrown if your code calls createSocket(). Simply override the method and the be done. :)

提交回复
热议问题