https://bz.apache.org/bugzilla/show_bug.cgi?id=69631

            Bug ID: 69631
           Summary: java.nio.channels.WritePendingException when using
                    https-openssl-nio2 and virtual threads
           Product: Tomcat 11
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Connectors
          Assignee: dev@tomcat.apache.org
          Reporter: sephir...@sephiroth-j.de
  Target Milestone: -------

When HTTPS is used in combination with Http11Nio2Protocol via OpenSSL and
useVirtualThreads is set to true, occasional exceptions are observed only with
the stacktrace and without a timestamp (a logger does not seem to be used).


```
Exception in thread "https-openssl-nio2-8443-virt-11363"
java.nio.channels.WritePendingException
        at
java.base/sun.nio.ch.AsynchronousSocketChannelImpl.write(AsynchronousSocketChannelImpl.java:352)
        at
java.base/sun.nio.ch.AsynchronousSocketChannelImpl.write(AsynchronousSocketChannelImpl.java:399)
        at
org.apache.tomcat.util.net.SecureNio2Channel$4.completed(SecureNio2Channel.java:1278)
        at
org.apache.tomcat.util.net.SecureNio2Channel$4.completed(SecureNio2Channel.java:1272)
        at java.base/sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:129)
        at java.base/sun.nio.ch.Invoker$2.run(Invoker.java:221)
        at
java.base/sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:113)
        at java.base/java.lang.VirtualThread.run(VirtualThread.java:329)
```

Our configuration is as follows

```
<?xml version="1.0" encoding="UTF-8"?>
<Server port="8005" shutdown="SHUTDOWN">
        <Listener
className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
        <Listener
className="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/>
        <Listener className="org.apache.catalina.core.AprLifecycleListener"
useAprConnector="true"/>
        <Listener
className="org.apache.catalina.security.TLSCertificateReloadListener"/>
        <Service name="Catalina">
                <Executor
className="org.apache.catalina.core.StandardVirtualThreadExecutor"/>
                <Connector
protocol="org.apache.coyote.http11.Http11Nio2Protocol" port="8080"
useVirtualThreads="true"/>
                <Connector
protocol="org.apache.coyote.http11.Http11Nio2Protocol" port="8443"
useVirtualThreads="true" SSLEnabled="true" scheme="https" secure="true">
                        <UpgradeProtocol
className="org.apache.coyote.http2.Http2Protocol"/>
                        <SSLHostConfig honorCipherOrder="false"
protocols="TLSv1.2,TLSv1.3" disableSessionTickets="true">
                        <Certificate
                               
certificateKeyFile="${TLS_CERTIFICATE_KEY_FILE}"
                               
certificateKeyPassword="${TLS_CERTIFICATE_KEY_PASSWORD}"
                                certificateFile="${TLS_CERTIFICATE_FILE}"
                               
certificateChainFile="${TLS_CERTIFICATE_CHAIN_FILE}"
                                type="${TLS_TYPE:-EC}"/>
                        </SSLHostConfig>
                </Connector>
                <Engine name="Catalina" defaultHost="localhost">
                        <Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
                                <Valve
className="org.apache.catalina.valves.ErrorReportValve" showReport="false"
showServerInfo="false"/>
                        </Host>
                </Engine>
        </Service>
</Server>
```

Version of Java
```
openjdk version "21.0.6" 2025-01-21 LTS
OpenJDK Runtime Environment Zulu21.40+17-CA (build 21.0.6+7-LTS)
OpenJDK 64-Bit Server VM Zulu21.40+17-CA (build 21.0.6+7-LTS, mixed mode,
sharing)
```

Other versions:
- APR 1.7.5
- OpenSSL 3.4.1
- TC-Native 2.0.8
- Tomcat 11.0.5

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to