rsocket / rsocket-cli

Command-line client for ReactiveSocket
Apache License 2.0
71 stars 22 forks source link

Malformed ws/wss urls produce non-descriptive error and is inconsistent with other url format #67

Closed lksvenoy-r7 closed 5 years ago

lksvenoy-r7 commented 5 years ago

Expected Behavior When running rsocket-cli with target specified as ws://127.0.0.1:8080, granted there is a running server and the other arguments specified are correct, the connection should successfully be established.

Actual Behavior The connection fails with a misleading error.

java.lang.IllegalArgumentException: Unable to parse url '' at reactor.netty.http.client.UriEndpointFactory.createUriEndpoint(UriEndpointFactory.java:69) at reactor.netty.http.client.UriEndpointFactory.createUriEndpoint(UriEndpointFactory.java:44) at reactor.netty.http.client.HttpClientConnect$HttpClientHandler.<init>(HttpClientConnect.java:503) at reactor.netty.http.client.HttpClientConnect$MonoHttpConnect.subscribe(HttpClientConnect.java:230) at reactor.core.publisher.MonoMap.subscribe(MonoMap.java:55) at reactor.core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:60) at reactor.core.publisher.Mono.subscribe(Mono.java:3694) at kotlinx.coroutines.reactive.AwaitKt.awaitOne(Await.kt:96) at kotlinx.coroutines.reactive.AwaitKt.awaitOne$default(Await.kt:94) at kotlinx.coroutines.reactive.AwaitKt.awaitFirst(Await.kt:25) at io.rsocket.cli.Main.buildClient(Main.kt:207) at io.rsocket.cli.Main.run(Main.kt:157) at io.rsocket.cli.Main$Companion$main$1.invokeSuspend(Main.kt:347) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:32) at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:233) at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.kt:116) at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:76) at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:53) at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source) at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:35) at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source) at io.rsocket.cli.Main$Companion.main(Main.kt:346) at io.rsocket.cli.Main.main(Main.kt)

This error happens because the UriEndpointFactory expected the URI Path variable to be set. The error is resolved by changing the ws uri to contain / at the end. The error is non-descriptive and inconsistent with the way tcp:// works.

Steps to Reproduce the Problem

  1. Start a websocket server on localhost:8080
  2. Run rsocket-cli --channel --dataFormat json -i "Hello" --debug ws://localhost:8080
  3. Observe the crash

Version: 1.14.0 Platform: macOS High Sierra, Macbook Pro (15-inch, 2018)