Scarlet Web 套接字库连接失败

use*_*620 5 android websocket kotlin

只是尝试在 Android 应用程序 (Kotlin) 和 NodeJS 服务器之间进行非常基本的 Websocket 通信。NodeJS 服务器一直在工作并与其他客户端连接,没有任何问题。我的基本代码如下所示:

    val client = OkHttpClient.Builder()
        .addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.HBASIC))
        .build()

    if (client != null) {
        val scarlet = Scarlet.Builder()
            .webSocketFactory(client.newWebSocketFactory("ws://192.168.2.33:3000"))
            .addMessageAdapterFactory(MoshiMessageAdapter.Factory())
            .addStreamAdapterFactory(RxJava2StreamAdapterFactory())
            .build()

        val myService = scarlet.create<MyService>()

        myService.observeWebSocketEvent()
            .subscribe { ev ->
                Log.e("WEB SOCKET", ev)
            }
    }
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

D/OkHttp: --> GET http://192.168.2.33:3000/
D/OkHttp: Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: ctY0bb8jl/mbF6KYGbSJBw==
Sec-WebSocket-Version: 13
--> END GET
D/OkHttp: <-- HTTP FAILED: java.io.IOException: unexpected end of stream on http://192.168.2.33:3000/...
Run Code Online (Sandbox Code Playgroud)

只是想知道是否有任何明显的事情表明我做错了。我正在使用以下依赖项:

    implementation 'com.github.tinder.scarlet:scarlet:0.1.7'
    implementation 'com.github.tinder.scarlet:scarlet-message-adapter-moshi:0.1.7'
    implementation 'com.github.tinder.scarlet:scarlet-stream-adapter-rxjava2:0.1.7'
    implementation 'com.github.tinder.scarlet:scarlet-websocket-okhttp:0.1.7'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.14.0'
Run Code Online (Sandbox Code Playgroud)