websocket Android okhttp3套接字连接问题

moiiocjp  于 2023-02-23  发布在  Android
关注(0)|答案(1)|浏览(219)

无法连接到套接字服务器,出现错误:java.net.ProtocolException: Expected HTTP 101 response but was '404 Not Found'.
代号:'

private fun run() {
    val client: OkHttpClient = OkHttpClient.Builder()
        .readTimeout(3, TimeUnit.SECONDS)
        .build()
    val request: Request = Request.Builder()
        .url(AppParams.SOCKET)
        .build()
    client.newWebSocket(request, this)
    client.dispatcher.executorService.shutdown()
}

'
URL格式为:"www.example.com网站"。https://url.com:3003/".
SocketIO库工作正常
已尝试删除前缀、更改端口、使用其它链路..

axr492tv

axr492tv1#

您应该将链接更改为“wss:url.com:3003/“

相关问题