Hi, On Mon, Sep 21, 2015 at 9:14 AM, Muhui Jiang <[email protected]> wrote: > Hi, > > But before send request, we have do the things below. > > FuturePromise<Session> sessionPromise = new FuturePromise<>(); > > client.connect(sslContextFactory, new InetSocketAddress(host, port), > new ServerSessionListener.Adapter(), sessionPromise); > > Session session = sessionPromise.get(5, TimeUnit.SECONDS); > > HttpFields requestFields = new HttpFields(); > > requestFields.put("User-Agent", client.getClass().getName() + "/" + > Jetty.VERSION); > > MetaData.Request metaData = new MetaData.Request("GET", new > HttpURI("https://"+host+":"+port+"/"), HttpVersion.HTTP_2, requestFields); > > HeadersFrame headersFrame = new HeadersFrame(0, metaData, null, > true); > > > then we can make the request: > > session.new stream(.....) > > > If I have a array contains 10000sites. for example websites[10000]; > > Which things should be done 10000 times? > > I have tried to start client once only. but I still failed.
HTTP2Client is very low level if you want to do a web bot. Does not do connection pooling, does not do async DNS lookup, etc. In any case, if you just have to send a single request for each website, what you have to do is: for each website client.connect() client.newStream() session.close() end Each of those 3 operations is async, so you have to wait for each one to complete (via callbacks) before issuing the next operation. You can do them in parallel. The error: java.lang.OutOfMemoryError: unable to create new native thread is likely due to a misconfiguration of your OS or thread pool. -- Simone Bordet ---- http://cometd.org http://webtide.com Developer advice, training, services and support from the Jetty & CometD experts. _______________________________________________ jetty-users mailing list [email protected] To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/jetty-users
