Skip to content
This repository has been archived by the owner on Oct 24, 2020. It is now read-only.

TLSv1.3 fails / java.nio.channels.ClosedChannelException: null #29

Closed
schnapster opened this issue Mar 27, 2020 · 0 comments · Fixed by #30
Closed

TLSv1.3 fails / java.nio.channels.ClosedChannelException: null #29

schnapster opened this issue Mar 27, 2020 · 0 comments · Fixed by #30

Comments

@schnapster
Copy link
Owner

schnapster commented Mar 27, 2020

Currently, on most JVM distributions, TLSv1.3 negotiation with Cloudflare is broken.
As soon as the audio websocket tries to connect to discord voice servers, the following or similar exception is thrown:

20:26:37.147 [XNIO-1 I/O-1] DEBUG io.undertow.request - UT005013: An IOException occurred
java.nio.channels.ClosedChannelException: null
	at io.undertow.protocols.ssl.SslConduit.doWrap(SslConduit.java:876)
	at io.undertow.protocols.ssl.SslConduit.doHandshake(SslConduit.java:649)
	at io.undertow.protocols.ssl.SslConduit.access$900(SslConduit.java:63)
	at io.undertow.protocols.ssl.SslConduit$SslReadReadyHandler.readReady(SslConduit.java:1137)
	at org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:88)
	at org.xnio.nio.WorkerThread.run(WorkerThread.java:561)
Exception in thread "main" java.lang.IllegalStateException: Failed to connect to wss://brazil0-test-proxy.discord.gg/
	at space.npstr.magma.impl.connections.hax.ClosingUndertowWebSocketClient$1.handleFailed(ClosingUndertowWebSocketClient.java:79)
	at org.xnio.IoFuture$HandlingNotifier.notify(IoFuture.java:215)
	at org.xnio.AbstractIoFuture$1.run(AbstractIoFuture.java:211)
	at org.xnio.IoUtils$2.execute(IoUtils.java:70)
	at org.xnio.AbstractIoFuture.runNotifier(AbstractIoFuture.java:354)
	at org.xnio.AbstractIoFuture.runAllNotifiers(AbstractIoFuture.java:233)
	at org.xnio.AbstractIoFuture.setException(AbstractIoFuture.java:251)
	at org.xnio.FutureResult.setException(FutureResult.java:89)
	at io.undertow.websockets.client.WebSocketClient$ConnectionBuilder$2.notify(WebSocketClient.java:342)
	at org.xnio.AbstractIoFuture$1.run(AbstractIoFuture.java:211)
	at org.xnio.IoUtils$2.execute(IoUtils.java:70)
	at org.xnio.AbstractIoFuture.runNotifier(AbstractIoFuture.java:354)
	at org.xnio.AbstractIoFuture.runAllNotifiers(AbstractIoFuture.java:233)
	at org.xnio.AbstractIoFuture.setException(AbstractIoFuture.java:251)
	at org.xnio.FutureResult.setException(FutureResult.java:89)
	at org.xnio.http.HttpUpgrade$HttpUpgradeState$StringWriteListener.handleEvent(HttpUpgrade.java:391)
	at org.xnio.http.HttpUpgrade$HttpUpgradeState$StringWriteListener.handleEvent(HttpUpgrade.java:372)
	at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
	at org.xnio.conduits.WriteReadyHandler$ChannelListenerHandler.writeReady(WriteReadyHandler.java:65)
	at io.undertow.protocols.ssl.SslConduit$SslWriteReadyHandler.writeReady(SslConduit.java:1273)
	at io.undertow.protocols.ssl.SslConduit$3.run(SslConduit.java:275)
	at org.xnio.nio.WorkerThread.safeRun(WorkerThread.java:582)
	at org.xnio.nio.WorkerThread.run(WorkerThread.java:466)
	Suppressed: java.lang.Exception: #block terminated with an error
		at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:93)
		at reactor.core.publisher.Mono.block(Mono.java:1494)
		at space.npstr.magma.Application.main(Application.java:59)
Caused by: java.nio.channels.ClosedChannelException
	at io.undertow.protocols.ssl.SslConduit.write(SslConduit.java:369)
	at org.xnio.conduits.ConduitStreamSinkChannel.write(ConduitStreamSinkChannel.java:150)
	at org.xnio.http.HttpUpgrade$HttpUpgradeState$StringWriteListener.handleEvent(HttpUpgrade.java:385)
	... 7 more

Until the root cause is found and fixed, a possible workaround is to specify TLSv1.2 in the SSL options as the preferred protocol. This is available since Magma 0.12.6

OptionMap sslOptions = OptionMap.create(
    Options.SSL_PROTOCOL, "TLSv1.2"
);
MagmaApi magmaApi = MagmaFactory.of(__ -> audioSendFactory, xnioOptions, sslOptions);
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant