https://kotlinlang.org logo
#ktor
Title
# ktor
h

Halil Ozercan

03/26/2020, 1:45 PM
Hey everyone, I’m using websockets from ktor server and client in a side project. Recently, I discovered that my client agents are disconnecting due to an internet connectivity issue and not realizing they’ve lost the connection, meanwile the server is well aware of disconnection. I’ve been using DefaultWebSocketImpl which means ping-pong should have caught this issue. After some digging, it turns out that ping-pong mechanism actually is not enabled by default on client sockets. Although client WebSockets feature takes
pingInterval
and
maxFrameSize
as constructor parameters,
install(WebSockets)
does not have a configuration option. So, I’m now stuck, not able to turn on a feature that already exists. Furthermore,
maxFrameSize
is passed to
DefaultWebSocketSession
as
Copy code
return DefaultWebSocketSession(this, pingInterval, maxFrameSize)
it turns out, third parameter is actually
timeoutMillis
not related to frameSize at all. I’ve made necessary changes to client WebSockets feature to actually take configuration and added
timeoutMillis
. Do you think I should make a pull request? It is a really small change and backward compatible.
This is the whole diff
m

marstran

03/26/2020, 2:20 PM
Changing the variable names is not a backwards compatible change. It will break callers who call it with named parameters. Also, why the change from
val
to
var
?
Also, where did
maxFrameSize
go?
e

e5l

03/26/2020, 2:49 PM
Hi @Halil Ozercan, thanks for the notice. Adding config fields looks perfect. Could you open the PR?
@e5l I created the PR with detailed explanation and documentation update.
🙏 1
5 Views