Adam S
06/18/2022, 7:09 PMwindow.location.href
, but now I need to set up some sort of 'proxy' so I can connect when developing locally
I've tried using the dev server option in build.gradle.kts
// build.gradle.kts
...
proxy = mutableMapOf(
"/ws" to mapOf(
"target" to "<http://localhost:12080>",
"secure" to false,
"ws" to true,
"changeOrigin" to true,
),
),
but I get an error in the application logs
<i> [webpack-dev-server] [HPM] Upgrading to WebSocket
<e> [webpack-dev-server] [HPM] WebSocket error: Error: read ECONNRESET
<e> at TCP.onStreamRead (node:internal/stream_base_commons:220:20) {
<e> errno: -4077,
<e> code: 'ECONNRESET',
<e> syscall: 'read'
<e> }
In the browser it tries to connect, but gets an Invalid frame header
error.
I saw that the KVision examples set up websockets proxys, but they look the same as what I have. What else do I need?
KVision 5.10.1, Kotlin/JS 1.7.0, more details hereRobert Jaros
06/18/2022, 8:12 PM"target" to "<ws://localhost:8080>"
and not http://...
Robert Jaros
06/18/2022, 8:12 PMAdam S
06/18/2022, 8:19 PM> Task :modules:web-map:browserDevelopmentRun
<i> [webpack-dev-server] [HPM] Proxy created: /tiles -> <http://localhost:12080>
<i> [webpack-dev-server] [HPM] Proxy created: /ws -> <ws://localhost:12080>
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: <http://localhost:3000/>
<i> [webpack-dev-server] On Your Network (IPv4): <http://192.168.178.59:3000/>
<i> [webpack-dev-server] Content not from webpack is served from '...\web-map\build/processedResources/js/main' directory
<i> [webpack-dev-server] [HPM] Upgrading to WebSocket
<e> [webpack-dev-server] [HPM] WebSocket error: Error: read ECONNRESET
<e> at TCP.onStreamRead (node:internal/stream_base_commons:220:20) {
<e> errno: -4077,
<e> code: 'ECONNRESET',
<e> syscall: 'read'
<e> }
Adam S
06/18/2022, 8:20 PMkotlin {
js(IR) {
browser {
runTask {
outputFileName = "main.bundle.js"
sourceMaps = false
devServer = KotlinWebpackConfig.DevServer(
open = false,
port = 3000,
proxy = mutableMapOf(
"/tiles" to mapOf(
"target" to "<http://localhost:12080>",
"secure" to false,
"changeOrigin" to true,
),
"/ws/*" to mapOf(
"target" to "<ws://localhost:12080>",
// "secure" to false,
"ws" to true,
// "changeOrigin" to true,
),
),
static = mutableListOf("$buildDir/processedResources/js/main")
)
}
webpackTask {
outputFileName = "main.bundle.js"
}
testTask {
useKarma {
useChromeHeadless()
}
}
}
binaries.executable()
}
Robert Jaros
06/18/2022, 8:24 PM/ws/*
doesn't include /ws
Adam S
06/18/2022, 8:24 PMhttp-proxy-middleware@2.0.6
? https://github.com/webpack/webpack-dev-server/issues/1642#issuecomment-1104408012
I don't know how to override that version thoughAdam S
06/18/2022, 8:24 PM/ws
, /ws/
, /ws/*
... no changeRobert Jaros
06/18/2022, 8:26 PM/ws/foo
and then check /ws/*
in webpack proxy?Robert Jaros
06/18/2022, 8:29 PMRobert Jaros
06/18/2022, 8:30 PMRobert Jaros
06/18/2022, 8:32 PMRobert Jaros
06/18/2022, 8:34 PMAdam S
06/18/2022, 8:37 PM"/ws/foo" to mapOf(
"target" to "<ws://localhost:12080>",
// "secure" to false,
"ws" to true,
// "changeOrigin" to true,
),
websocker server is up at <ws://localhost:12080/ws/foo>
, the browser is pointing to <ws://localhost:3000/ws/foo>
I'm not getting any data, but that might be a bug on the websocket server side (coroutines are confusing)Adam S
06/18/2022, 8:38 PM