2 u013179958 u013179958 于 2017.08.13 16:19 提问

压力测试的时候,抛出一个异常

设置了300个线程去压力测试软件
于是报了这个一个异常,谁知道是怎么回事?
网上有人说是tomcat最大线程数的事

 java.net.SocketException: Permission denied: connect
    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at java.net.Socket.connect(Socket.java:538)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:242)
    at sun.net.www.http.HttpClient.New(HttpClient.java:339)
    at sun.net.www.http.HttpClient.New(HttpClient.java:357)
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1202)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1138)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1032)
    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:966)
    at org.apache.jmeter.protocol.http.sampler.HTTPJavaImpl.sample(HTTPJavaImpl.java:482)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:74)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1146)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1135)
    at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:465)
    at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:410)
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:241)
    at java.lang.Thread.run(Thread.java:748)

1个回答

Small_Mouse0
Small_Mouse0   2017.08.13 16:22

权限问题,,

1、先用浏览器访问一下,看能不能访问

2、代码如下加上试一下:

 HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestProperty( "User-agent", "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)" );

这行的意思是骗对方网站,让它认为你是在用IE访问,而不是机器访问。

参考链接:http://bbs.csdn.net/topics/310129159

希望对你有帮助

Csdn user default icon
上传中...
上传图片
插入图片