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

With reactor-core >3.3.5, Calling WebSocketSession.close() in client.execute(uri, handler) logs an error #714

Open
jonenst opened this issue Sep 14, 2020 · 0 comments

Comments

@jonenst
Copy link

jonenst commented Sep 14, 2020

Hi,

The following test code connects to a websocket server and then closes the connection (to prove that the server is correctly accepting websockets connections):

    @Test
    public void echo() {
        WebSocketClient client = new StandardWebSocketClient();
        client.execute(getUrl("/notify"), WebSocketSession::close).block();
    }
    protected URI getUrl(String path) {
        return URI.create("ws://localhost:" + this.port + path);
    }

With reactor 3.3.4, it works as expected. With reactor 3.3.5, even though the test still works, I get the following log:

17:05:26.766 [Grizzly(1)] ERROR reactor.core.publisher.Operators - Operator called default onErrorDropped
java.lang.IllegalStateException: The connection has been closed.
	at org.glassfish.tyrus.core.TyrusSession.checkConnectionState(TyrusSession.java:513)
	Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
Error has been observed at the following site(s):
	|_ checkpoint ⇢ ws://localhost:46257/notify [StandardWebSocketHandlerAdapter]
Stack trace:
		at org.glassfish.tyrus.core.TyrusSession.checkConnectionState(TyrusSession.java:513)
		at org.glassfish.tyrus.core.TyrusSession.close(TyrusSession.java:208)
		at org.springframework.web.reactive.socket.adapter.StandardWebSocketSession.close(StandardWebSocketSession.java:103)
		at org.springframework.web.reactive.socket.WebSocketSession.close(WebSocketSession.java:89)
		at org.springframework.web.reactive.socket.adapter.AbstractListenerWebSocketSession.onComplete(AbstractListenerWebSocketSession.java:218)
		at reactor.core.publisher.StrictSubscriber.onComplete(StrictSubscriber.java:123)
		at reactor.core.publisher.Operators.complete(Operators.java:135)
		at reactor.core.publisher.MonoEmpty.subscribe(MonoEmpty.java:45)
		at reactor.core.publisher.Mono.subscribe(Mono.java:4218)
		at org.springframework.web.reactive.socket.adapter.StandardWebSocketHandlerAdapter.onOpen(StandardWebSocketHandlerAdapter.java:86)
		at org.glassfish.tyrus.core.TyrusEndpointWrapper.onConnect(TyrusEndpointWrapper.java:750)
		at org.glassfish.tyrus.core.TyrusWebSocket.onConnect(TyrusWebSocket.java:139)
		at org.glassfish.tyrus.client.TyrusClientEngine.processUpgradeResponse(TyrusClientEngine.java:554)
		at org.glassfish.tyrus.client.TyrusClientEngine.handleSwitchProtocol(TyrusClientEngine.java:317)
		at org.glassfish.tyrus.client.TyrusClientEngine.processResponse(TyrusClientEngine.java:254)
		at org.glassfish.tyrus.container.grizzly.client.GrizzlyClientFilter.handleHandshake(GrizzlyClientFilter.java:322)
		at org.glassfish.tyrus.container.grizzly.client.GrizzlyClientFilter.handleRead(GrizzlyClientFilter.java:291)
		at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
		at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
		at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
		at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
		at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
		at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
		at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
		at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
		at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
		at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
		at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
		at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
		at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
		at java.base/java.lang.Thread.run(Thread.java:834)

I tried defering the call to close() hoping it was some kind of race condition by using the following instead:

        client.execute(getUrl("/notify"), webSocketSession ->
        Mono.empty().delaySubscription(Duration.ofMillis(5000))
                .then(Mono.defer(webSocketSession::close))
        ).block()

But I still get the spurious error log.

I'm using org.glassfish.tyrus.bundles:tyrus-standalone-client 1.17

Is the spurious log a bug in my code or in the library ?
Thanks,
Jon

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

1 participant