在公司代理后面使用Ktor作为Websocket客户端

时间:2019-04-29 12:45:59

标签: kotlin proxy http-proxy ktor

我目前正在尝试建立一个使用Ktor和CIO编写的非常简单的Websocket客户端

            val client = HttpClient(CIO).config {
                install(WebSockets)
            }

            client.wss(HttpMethod.Get, "some-host", 443, "/wsock") {
                val initialFrame = incoming.receive()
                if (initialFrame is Frame.Text) {
                    println(initialFrame.readText())
                }

                while (true) {
                    val nextMessage = readLine() ?: "<empty>"
                    send(Frame.Text(nextMessage))

                    var frame = incoming.receive()
                    if (frame is Frame.Text) {
                        println(frame.readText())
                    }
                }
            }

            client.close()

这在我的公用计算机上运行良好,但是在企业代理之后却失败了。我做了一些研究,但找不到CIO Engine的任何代理设置,而且它似乎不尊重JVM选项http(s).proxyHost / .proxyPort

有人让它起作用吗?

0 个答案:

没有答案
相关问题