为什么直接在网站上访问这个内网的地址不会报500, 而用一个这种的多线程会报500,外网的地址却不报500

flink58 发布于 2016/05/25 11:54
阅读 400
收藏 0
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Semaphore;

import com.fz.util.HttpClientUtils;

public class ConcurrentTest {
	private static int thread_num = 200;
	private static int client_num = 500;

	public static void main(String[] args) {
		ExecutorService exec = Executors.newCachedThreadPool();

		final Semaphore semp = new Semaphore(thread_num);

		for (int index = 0; index < client_num; index++) {

			final int NO = index;
			
		

			Runnable run = new Runnable() {
				public void run() {
					try {
						final HttpClientUtils client= new HttpClientUtils();
						semp.acquire();
						String url = "http://192.168.2.111:80/rec/user/user.action?phone=1231312&ip=192.168.2.44&udid=HDXHHH-ZZ-YQ4HL-824&lat=31.375769250067&lng=120.630762208730&id=HDXHHH-ZZ-YQ4HL-824";
//						String url = "https://www.baidu.com/s?ie=UTF-8&wd=%E4%BF%AE%E6%94%B9max_allowed_packet";
						String res=	 client.connctionURL_Params(url, "GET", "");
						System.out.println(res.length());
						System.out.println("Thread:" + NO);
						//业务逻辑
						semp.release();
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
			};
			exec.execute(run);
		}
		System.out.println("----exec.shutdown()-----");
		exec.shutdown();
	}
}

为什么直接在网站上访问这个内网的地址不会报500, 而用一个这种的多线程会报500,外网的地址却不报500



Thread:302

java.io.IOException: Server returned HTTP response code: 500 for URL: http://192.168.2.230:7373/rec/user/user?udid=HDXHHH-ZZ-YQ4HL-824&lat=31.375769250067&lng=120.630762208730&id=HDXHHH-ZZ-YQ4HL-824
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1839)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1440)
at com.fz.util.HttpClientUtils.connctionURL_Params(HttpClientUtils.java:51)
at com.qjj.test.ConcurrentTest$1.run(ConcurrentTest.java:30)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
java.io.IOException: Server returned HTTP response code: 500 for URL: http://192.168.2.230:7373/rec/user/user_getTopHouse.action?phone=13815923338&ip=192.168.2.44&udid=HDXHHH-ZZ-YQ4HL-824&lat=31.375769250067&lng=120.630762208730&id=HDXHHH-ZZ-YQ4HL-824
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1839)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1440)
at com.fz.util.HttpClientUtils.connctionURL_Params(HttpClientUtils.java:51)
at com.qjj.test.ConcurrentTest$1.run(ConcurrentTest.java:30)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
加载中
0
郭伟伟
郭伟伟
你的服务器撑不住这么多请求
flink58
flink58
不是这个问题,服务器访问不了,报500呀
返回顶部
顶部