Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibility to select http connector #207

Closed
ghost opened this issue Jul 30, 2020 · 3 comments
Closed

Possibility to select http connector #207

ghost opened this issue Jul 30, 2020 · 3 comments
Assignees

Comments

@ghost
Copy link

ghost commented Jul 30, 2020

Hi,
Currently, the webapp-runner has the http "nio" connector hard-coded. Tomcat also offers a "nio2" and an "apr" connector. Would it be possible to make that configurable? For the "apr" connector, the "AprLifecycleListener" must be set up with correct attributes (for example, switch off ssl, switch off openssl and enable apr), and the native libraries "tcnative" and "apr" must be available in the java.library.path.

@jkutner
Copy link
Contributor

jkutner commented Jul 31, 2020

@tbf2000 that seems like something we could do. How similar is the interface for each connector?

If you're interested in to prototyping it this is a good place to start.

@ghost
Copy link
Author

ghost commented Jul 31, 2020

The interface of the APR connector is no challenge. You can just set instatiate it using the apr-specific classname:

	String connectorClassName = tomcatNative ? "org.apache.coyote.http11.Http11AprProtocol"
			: "org.apache.coyote.http11.Http11NioProtocol";
	Connector httpConnector = new Connector(connectorClassName);

But before you do that, you have to add the AprLifecycleListener to the Tomcat instance:

	LifecycleListener[] lifecycleListeners = tomcat.getServer().findLifecycleListeners();
	AprLifecycleListener aprLifecycleListener = null;
	if (null != lifecycleListeners) {
		for (LifecycleListener lifecycleListener : lifecycleListeners) {
			if (lifecycleListener instanceof AprLifecycleListener) {
				aprLifecycleListener = (AprLifecycleListener) lifecycleListener;
			}
		}
	}
	if (null == aprLifecycleListener) {
		aprLifecycleListener = new AprLifecycleListener();
		tomcat.getServer().addLifecycleListener(aprLifecycleListener);
	}
	aprLifecycleListener.setUseAprConnector(true);
	aprLifecycleListener.setSSLEngine("off");
	aprLifecycleListener.setUseOpenSSL(false);

For "nio2", I do not know, but I do not expect any surprises.

@Malax
Copy link
Member

Malax commented Nov 11, 2022

Hello! Since this is an old issue and many things have changed since it was opened I will close it for now. Feel absolutely free to re-open it if it is still relevant so we can work on it! :)

@Malax Malax closed this as completed Nov 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants