You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "peter curtis (JIRA)" <ji...@apache.org> on 2008/02/11 18:08:08 UTC

[jira] Created: (HTTPCORE-145) After fewer minutes IODispatchers workers stop attenting requests

After fewer minutes IODispatchers workers stop attenting requests
-----------------------------------------------------------------

                 Key: HTTPCORE-145
                 URL: https://issues.apache.org/jira/browse/HTTPCORE-145
             Project: HttpComponents Core
          Issue Type: Bug
          Components: HttpCore NIO
    Affects Versions: 4.0-beta2
         Environment: Linux Debian and Windows
            Reporter: peter curtis
            Priority: Critical



I have a NIO HTTP server dispatching a massive loading, after fewer minutes IODispathers workers (10 workers) unexpecteadly stop attending requests.
I am using JProfiler and I have checked that after a while of  good performance, one of threads fall into running and the rest in IO netwoks tasks. After that the application silently stops attending.

Thank you in advance.



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] Resolved: (HTTPCORE-145) After fewer minutes IODispatchers workers stop attenting requests

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCORE-145?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oleg Kalnichevski resolved HTTPCORE-145.
----------------------------------------

    Resolution: Cannot Reproduce

> After fewer minutes IODispatchers workers stop attenting requests
> -----------------------------------------------------------------
>
>                 Key: HTTPCORE-145
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-145
>             Project: HttpComponents Core
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0-beta2
>         Environment: Linux Debian and Windows
>            Reporter: peter curtis
>            Priority: Critical
>
> I have a NIO HTTP server dispatching a massive loading, after fewer minutes IODispathers workers (10 workers) unexpecteadly stop attending requests.
> I am using JProfiler and I have checked that after a while of  good performance, one of threads fall into running and the rest in IO netwoks tasks. After that the application silently stops attending.
> Thank you in advance.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] Commented: (HTTPCORE-145) After fewer minutes IODispatchers workers stop attenting requests

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-145?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12568020#action_12568020 ] 

Oleg Kalnichevski commented on HTTPCORE-145:
--------------------------------------------

Peter, 

That does not help me much.

Please _do_ try to answer the questions if you expect us to help you. Exactly what _version_ of HttpCore are you using? Are you seeing _any_ exceptions? 

Threads do not terminate for no reason. If a thread terminates abnormally this is because an unchecked exception must have killed it. 

Please _do_ try to reproduce the problem with a self-contained test case.

Oleg

> After fewer minutes IODispatchers workers stop attenting requests
> -----------------------------------------------------------------
>
>                 Key: HTTPCORE-145
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-145
>             Project: HttpComponents Core
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0-beta2
>         Environment: Linux Debian and Windows
>            Reporter: peter curtis
>            Priority: Critical
>
> I have a NIO HTTP server dispatching a massive loading, after fewer minutes IODispathers workers (10 workers) unexpecteadly stop attending requests.
> I am using JProfiler and I have checked that after a while of  good performance, one of threads fall into running and the rest in IO netwoks tasks. After that the application silently stops attending.
> Thank you in advance.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] Commented: (HTTPCORE-145) After fewer minutes IODispatchers workers stop attenting requests

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-145?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12567801#action_12567801 ] 

Oleg Kalnichevski commented on HTTPCORE-145:
--------------------------------------------

> after fewer minutes IODispathers workers (10 workers) unexpecteadly stop attending requests

Peter,
What exactly goes wrong? An exception? A thread deadlock? How exactly does the problem manifest itself? Can you give at least some details as to how I can reproduce the problem? A test case would be great.

Besides, exactly what version of HttpCore are you using? 4.0-beta2 has not been released yet

Oleg

> After fewer minutes IODispatchers workers stop attenting requests
> -----------------------------------------------------------------
>
>                 Key: HTTPCORE-145
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-145
>             Project: HttpComponents Core
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0-beta2
>         Environment: Linux Debian and Windows
>            Reporter: peter curtis
>            Priority: Critical
>
> I have a NIO HTTP server dispatching a massive loading, after fewer minutes IODispathers workers (10 workers) unexpecteadly stop attending requests.
> I am using JProfiler and I have checked that after a while of  good performance, one of threads fall into running and the rest in IO netwoks tasks. After that the application silently stops attending.
> Thank you in advance.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] Commented: (HTTPCORE-145) After fewer minutes IODispatchers workers stop attenting requests

Posted by "peter curtis (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-145?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12568068#action_12568068 ] 

peter curtis commented on HTTPCORE-145:
---------------------------------------

Oleg

We have commented this line of code 
  //response.setEntity(body); 
and the unexpected behavior has stopped happening.

We have decided not inform responses as the exception is clear in the server. Nevertheless we prefer to keep you informed whether it is a bug in handling responses.
The version we are using is 4.0-beta2 

Many thanks for your prompting help.

> After fewer minutes IODispatchers workers stop attenting requests
> -----------------------------------------------------------------
>
>                 Key: HTTPCORE-145
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-145
>             Project: HttpComponents Core
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0-beta2
>         Environment: Linux Debian and Windows
>            Reporter: peter curtis
>            Priority: Critical
>
> I have a NIO HTTP server dispatching a massive loading, after fewer minutes IODispathers workers (10 workers) unexpecteadly stop attending requests.
> I am using JProfiler and I have checked that after a while of  good performance, one of threads fall into running and the rest in IO netwoks tasks. After that the application silently stops attending.
> Thank you in advance.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] Commented: (HTTPCORE-145) After fewer minutes IODispatchers workers stop attenting requests

Posted by "peter curtis (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-145?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12567998#action_12567998 ] 

peter curtis commented on HTTPCORE-145:
---------------------------------------

Thanks in advance, Oleg.

I am using this code for a propietary application. This application needs serializing a huge amount of objects, for this reason we opt to choose NIO as the best solution for these requirements. When we are checking this code with JProfiler and after a fewer minutes of good performance. Just in the moment that one of the IODispatcher threads appears in green (meaning running state) the rest of the IODispatchers fall into IO networks tasks. Since this moment the application stops receiving requests. I haven't  any idea what is happening.  Apparently, all that it seems that NIO selectors do not run properly. 


private class ControllerServerChannel {
		class HttpHandler implements HttpRequestHandler {
		
			public HttpHandler() {
			}
		
			public void handle(final HttpRequest request, final HttpResponse response, final HttpContext context) throws HttpException, IOException {
		
				ByteArrayOutputStream baos = new ByteArrayOutputStream();
				HeaderIterator it = request.headerIterator();
				byte[] entityContent;
				URI uri = null;
		
				baos.write(request.getRequestLine().toString().getBytes());
				baos.write(RPC.EOL);
				while (it.hasNext()) {
					baos.write(it.nextHeader().toString().getBytes());
					baos.write(RPC.EOL);
				}
		
				baos.write(RPC.EOL);
				if (request instanceof HttpEntityEnclosingRequest) {
					HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
					entity.consumeContent();
					entityContent = EntityUtils.toByteArray(entity);
					baos.write(entityContent);
				}
		
				try {
					uri = new URI(URLDecoder.decode(request.getRequestLine().getUri(), "UTF-8"));
				} catch (URISyntaxException e) {
				}
		
				InputStream in = new ByteArrayInputStream(baos.toByteArray());
				OutputStream out = new ByteArrayOutputStream();
				final InputOutput io = new InputOutput(uri, in, out);
				baos.close();
		
				EntityTemplate body = new EntityTemplate(new ContentProducer() {
		
					public void writeTo(final OutputStream outstream) throws IOException {
						outstream.write(((ByteArrayOutputStream) io.getOutputStream()).toByteArray());
					}
				});
				workerGroup.process(io, io);
				response.setEntity(body);
			}
		
		}

		private ListeningIOReactor ioReactor;
		private HttpParams params;
		private BufferingHttpServiceHandler handler;
		private InetSocketAddress inetSocketAddress;
		private SSLContext sslContext;

		ControllerServerChannel(ChannelServiceConfig serviceCfg) throws Exception {
			SocketEndPointConfig socketEndPointConfig = (SocketEndPointConfig) serviceCfg.getEndPointConfig();
			params = new BasicHttpParams();
			params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 5000).setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024).setBooleanParameter(
					CoreConnectionPNames.STALE_CONNECTION_CHECK, false).setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, false).setParameter(CoreProtocolPNames.ORIGIN_SERVER,
					"HttpComponents/1.1");
			inetSocketAddress = getInetSocketAddress(socketEndPointConfig);
			sslContext = getSSLContext(socketEndPointConfig.getSSLParams());
			BasicHttpProcessor httpproc = new BasicHttpProcessor();
			httpproc.addInterceptor(new ResponseDate());
			httpproc.addInterceptor(new ResponseServer());
			httpproc.addInterceptor(new ResponseContent());
			httpproc.addInterceptor(new ResponseConnControl());

			handler = new BufferingHttpServiceHandler(httpproc, new DefaultHttpResponseFactory(), new DefaultConnectionReuseStrategy(), params);

			// Set up request handlers
			HttpRequestHandlerRegistry reqistry = new HttpRequestHandlerRegistry();
			reqistry.register("*", new HttpHandler());

			handler.setHandlerResolver(reqistry);
		}

		private void start() throws IOException {

			Thread t = new Thread(new Runnable() {
				public void run() {
					try {
						IOEventDispatch ioEventDispatch;
						if (isSecure()) {
							ioEventDispatch = new SSLServerIOEventDispatch(handler, sslContext, params);
						} else
							ioEventDispatch = new DefaultServerIOEventDispatch(handler, params);

						ListeningIOReactor ioReactor = new DefaultListeningIOReactor(1, params);
						ioReactor.listen(inetSocketAddress);
						ioReactor.execute(ioEventDispatch);
					} catch (IOException ioe) {
						Logger.log(this, "startService()", "Error starting socket", ioe, Logger.Severity.WARNING);
					}
				}
			}, "LogServer:ChannelService");
			t.setPriority(Thread.MAX_PRIORITY);
			t.start();
		}

		private void stop() throws IOException {
			ioReactor.shutdown();
		}

		private boolean isSecure() {
			return sslContext != null;
		}

		private int getPort() {
			return inetSocketAddress.getPort();
		}

		private InetSocketAddress getInetSocketAddress(SocketEndPointConfig config) throws ConfigInitializationException {

			InetAddress bindAddress = null;
			int port;
			String bindIP = config.getBindIP();
			if (bindIP != null && bindIP.length() > 0) {
				try {
					bindAddress = InetAddress.getByName(bindIP);
				} catch (UnknownHostException uhe) {
					String msg = "Specified address not valid for: " + bindIP;
					Logger.log(this, "init(SocketEndPointConfig)", msg, Logger.Severity.SEVERE_ERROR);
					throw new ConfigInitializationException(msg, uhe);
				}
			}
			port = config.getPort();

			if (port < 0) {
				String msg = "Server port cannot be negative [" + port + "]";
				Logger.log(this, "init(SocketEndPointConfig)", msg, Logger.Severity.SEVERE_ERROR);
				throw new ConfigInitializationException(msg);
			} else if (port > 65535) {
				String msg = "Server port cannot be bigger than 65535 [" + port + "]";
				Logger.log(this, "init(SocketEndPointConfig)", msg, Logger.Severity.SEVERE_ERROR);
				throw new ConfigInitializationException(msg);
			}
			return new InetSocketAddress(bindAddress, port);
		}

		private SSLContext getSSLContext(SSLParamsConfig spc) throws IOException {
			SSLContext ctx = null;
			if (spc == null)
				return ctx;
			String keystore = spc.getKeyStore().getAbsolutePath();
			char[] passphrase = EncryptedPassword.decryptProperty(spc.getKeyStorePassword()).toCharArray();

			try {
				java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
				ctx = SSLContext.getInstance("TLS");
				KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
				KeyStore ks = KeyStore.getInstance("JKS");
				ks.load(new FileInputStream(keystore), passphrase);
				kmf.init(ks, passphrase);
				ctx.init(kmf.getKeyManagers(), null, null);
			} catch (java.security.GeneralSecurityException gse) {
				throw new IOException(gse.getMessage());
			}
			return ctx;
		}

	}


> After fewer minutes IODispatchers workers stop attenting requests
> -----------------------------------------------------------------
>
>                 Key: HTTPCORE-145
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-145
>             Project: HttpComponents Core
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0-beta2
>         Environment: Linux Debian and Windows
>            Reporter: peter curtis
>            Priority: Critical
>
> I have a NIO HTTP server dispatching a massive loading, after fewer minutes IODispathers workers (10 workers) unexpecteadly stop attending requests.
> I am using JProfiler and I have checked that after a while of  good performance, one of threads fall into running and the rest in IO netwoks tasks. After that the application silently stops attending.
> Thank you in advance.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org