-
lovetox
hm, if i lose internet connection, say disable wlan, my socket does not really care, i can still send endless data on it
-
lovetox
i thought that he would throw some error, but nothing
-
lovetox
now i read a bit about it and seems this works as intended
-
lovetox
so the only way to know if i lost connection is application layer pings
-
lovetox
can someone confirm this
-
lovetox
?
-
lovetox
and there is some other functionality SO_KEEPALIVE, where the system tests if a socket is still connected
-
lovetox
but according to the internet the timeout is 2 hours on linux
-
lovetox
so not really useable as a client
-
MattJ
Yes, this is all correct
-
MattJ
There are platform-specific ways to reduce the timeout
-
lovetox
damn, brilliant design
-
defanor
Well, the send buffer is finite. And according to tcp(7) (assuming it's about TCP), keep-alive probes would lead to timing out in about 11 minutes on Linux by default, while retransmission attempts would last 13 to 30 minutes. And then there's TCP_USER_TIMEOUT, and I think I've observed it timing out in just a few minutes (not sure why).
-
lovetox
yeah i was looking for something in the range of seconds
-
jonas’
lovetox, anything in the range of seconds would make things fail on EDGE or GPRS type connections quickly
-
pulkomandy
Or even wifi if you're a bit far from the router
-
MattJ
And consume battery/bandwidth
-
pulkomandy
Or ethernet if you just unplug the cable for a few seconds to untangle it :]
-
jonas’
in the case of EDGE/GPRS, you can easily get into a fun loop with packets from your closed connection cluttering the bandwidth, making your new connection choke right away.
-
lovetox
hm, so what timeout would you suggest?
-
lovetox
i think its useful for the client to know if the connection broke down
-
jonas’
timeouts are always wrong
-
lovetox
problem is if the connection broke down, and client doesnt notice it, stuff stops working
-
jonas’
indeed
-
jonas’
I suggest to have two timeouts
-
lovetox
for sending a message i can just show some icon that indicates the message didnt yet reach the server
-
jonas’
one I call the `soft_timeout`, which is the maximum time you spend without receiving any data from the server
-
jonas’
(be it whitespace or a stanza)
-
jonas’
if the soft timeout elapses, you send a ping
-
jonas’
and you wait for at most `round_trip_time` (the second timeout) to receive something (doesn’t have to be a reply to your ping, anything will do)
-
jonas’
the good thing about this is that with high-delay links, you’ll still most of the time receive things and thus know that your stream is alive
-
lovetox
yeah i implemented this just now
-
jonas’
you also save on sending pings when you get stanzas from the server (= saved energy)
-
lovetox
but what is the max roundtrip tie✎ -
lovetox
but what is the max roundtrip time ✏
-
lovetox
is 10 seconds good?
-
jonas’
in case of gajim, I’d probably set something like 5 minutes for the soft timeout, and auto-calibrate the round-trip time based on IQ round trips
-
lovetox
60 seconds?
-
jonas’
something between 60s and 120s is probably ok
-
lovetox
5 minutes is way to high, as i said stuff stops working, if user opens his profile it just shows a endless loading screen, if he wants to join a MUC, shows a loading screen, etc etc
-
jonas’
lovetox, you can make it more interactive on the application layet
-
lovetox
and at this time i want to give the user an indication, hey your connection may be broke down
-
jonas’
e.g. if after 15s you have no reply, you could do othre things
-
jonas’
such as pinging google or so
-
lovetox
but if i have a 5 minute soft timeout, i cant give the user any indication
-
jonas’
and if you can’t ping google, suggest that the internte may be down
-
jonas’
oh you can
-
jonas’
have an even softer 15s timeout on your requests (IQs, MUC joins etc.) which triggers some additional action to make the UX smooth
-
jonas’
"This is taking longer than expected. Is your internet working?"
-
jonas’
and also listen for OS events about connectivity changes
-
lovetox
so 15 seconds :)
-
jonas’
if you get a "reconnected to network X" event from the OS, discard your stream and resume using '198
-
lovetox
thats the answer i wanted
-
jonas’
but 15 seconds isn’t the time after which you should throw away the stream
-
jonas’
that’s just when you start talking to your user
-
jonas’
that’s also not the time after which you start sending pings
-
jonas’
because you just sent a "ping"
-
jonas’
(which is your request)
-
lovetox
yeah jonas’ i get it :)
-
jonas’
uh, although, what could be fun is trying to establish a new stream
-
lovetox
i was always talking about the time i wait for the poing
-
jonas’
in the background
-
jonas’
and if you notice that this works very quickly, but your request is slow, you send a ping to the server. if you don’t get a reply within the time it took to get the new stream past TLS, you know that your stream is borked and you should '198 resume on the new stream and discard the old one
-
jonas’
that’s neat actually
-
jonas’
establishing a new TCP connection and doing TLS is not that expensive in number of packets and as good as a test as anything else
-
jonas’
(it’ll also not clutter your own send buffers further, you can simply discard the new connection (along with its buffers) easily if it doesn’t work out)
-
lovetox
jonas’, sorry sounds way to complicated and over-engineered
-
lovetox
i wait X seconds, and throw the stream away, much easier
-
lovetox
thats what we have stream management for, for fast reconnects
-
jonas’
lovetox, that’ll really hurt you
-
jonas’
on a bad mobile link
-
lovetox
on bad mobile link, stuff will be bad, no suprise for the user :)
-
lovetox
but the whole topic is a nightmare, we have many actions on xmpp that need a response
-
lovetox
so many action will look to the user like, he clicks something but nothing happens
-
Zash
Show a spinner if it takes more than a few seconds
-
lovetox
for some things thats a fine approach
-
lovetox
for others its not so nice
-
lovetox
deleting a contact from your rosterfor example
-
lovetox
dont want to show a dialog with a spinner for that
-
Zash
Show it on the contact then. Like, replace the avatar or status icon or something
-
lovetox
you really have to design the whole application for this case
-
lovetox
what i think i will be doing, let the user send message when we lost connection
-
lovetox
but disable every other action
-
flow
> lovetox> damn, brilliant design when is a connection "lost"? I don't think there is a better design without loosing some other (desirable) properties
-
Zash
That's what you get when you emulate a circuit over a packet-switched network. All sorts of fun!
-
jonas’
lovetox, or just pretend that it has happened for things where you’re rather certain that you can enforce it to happen eventually
-
jonas’
for example, contact deletion
-
jonas’
queue the operation up and do it when you have connectivity and hide the element from the UI
-
pep.
And then users get confused when they use another client that has connectivity :/
-
pep.
I see the appeal in what you say but I'm not entirely sure I like it
-
lovetox
jonas’, sounds easy, but reality is much harder
-
lovetox
you can invest thousands of lines of code into this, and it still will be buggy
-
lovetox
or you just tell the user, hey right now you cant delete, wait until you have a proper connection to the server
-
lovetox
which is totally fine in my book, i dont think anyone expects to do server operations while offline
-
moparisthebest
lovetox: you can change the SO_KEEPALIVE interval on Linux, it's settable if you are root
-
pep.
yay gajim as root :P
-
Zash
Just run it in a container.
-
pep.
yay gajim as root in a container!
-
jonas’
a.k.a. flatpak?
-
jonas’
or was it snap?
-
Zash
why not both?
-
pep.
Is the process really root? Isn't bubblewrap used just to spawn the thing?
-
jonas’
pep., I was making fun of those
-
jonas’
probably not root ;)
-
moparisthebest
Well no gajim wouldn't change it, the machine administrator would
-
moparisthebest
With sysctl
-
Zash
Isn't there a per-process/-socket option you can poke if your socket library doesn't hide it from you?
-
moparisthebest
Not for keepalive iirc
-
moparisthebest
Don't worry TCP's replacement is all in userspace not kernel so you can do whatever
-
Zash
:(
-
Zash
But I was excited about TLS in kernel space
-
Link Mauve
I still want to play with that.
-
Link Mauve
I should have a look in rustls.
-
lovetox
so if i do the xmpp pings, i guess i dont need the send every X seconds a whitespace
-
lovetox
or isthis useful for something else
-
Link Mauve
The whitespace is a keepalive.
-
lovetox
yeah though i just learned a socket does not break down, even if i cut the internet, so keeping it alive is not really the issue here
-
MattJ
Heh
-
MattJ
Some (too many) routers like to silently terminate idle connections
-
lovetox
ok but sending a xmpp ping on a idle connection every 15 seconds should keep it alive
-
MattJ
Sure
-
lovetox
im asking if i need both
-
MattJ
15 seconds is kinda frequent :/
-
MattJ
You could at least use 198 <r>/<a> for pings, which are lighter
-
Zash
How about 14 minutes
-
Link Mauve
lovetox, that sounds like a battery drainer.
-
Link Mauve
Pidgin does that AFAIK, and it’s terrible.
-
Link Mauve
Don’t be like Pidgin.
-
lovetox
hm or i depend on a network manager, to tell me if the internet is down
-
Link Mauve
Aren’t you already doing that with nm?
-
Link Mauve
But jonas’’s approach of using XEP-0198 stream resumption looks quite elegant to me.
-
Link Mauve
That’s what I’d do if I were to start something from scratch again.
-
lovetox
what approach is that?
-
Link Mauve
The one from 10:24:16 CET.
-
Zash
Just trying a new TCP connection to the server would at least tell you something about whether it's the existing connection that's broken or all connectivity
-
Link Mauve
or all connectivity to the server*
-
lovetox
but thats what a network manager is for
-
lovetox
...
-
Zash
It won't detect if someone trips over a cable in the building switch room
-
Link Mauve
Seems like it would require running one though.
-
Zash
or the server suddenly explodes
-
lovetox
i think we are mixing 2 things here
-
lovetox
detecting if my remote is gone
-
lovetox
and detecting if my internet is gone
-
lovetox
or is this the same thing?
-
lovetox
i hope not
-
Link Mauve
What is your end goal?
-
lovetox
either way, network manager tells me when there is no route to the internet, reading the manual
-
lovetox
so this includes tripping over my cable
-
lovetox
Link Mauve, detecting when i have no connection to the server
-
Link Mauve
lovetox, why do you need to know about the Internet then?
-
Link Mauve
And also, what do you want to do in such a case?
-
Link Mauve
What about if the kernel eventually flushes its buffers and messages you sent now got sent?
-
lovetox
i show the user that there is no connection and limit what he can do
-
Link Mauve
That sounds like bad UX when you can instead remember what the user did and then figure out whether it got done or not on stream resumption.
-
Link Mauve
Meh, stupid Freenode sending me tons of presences from IRC…
-
Zash
There was just a notice about them doing some maintenence
-
Link Mauve
poezio is still spending all of my CPU time handling those presences…
-
lovetox
so just a simple example
-
lovetox
its easy to just store the stanzas that are going out and on failed resumption replay them
-
lovetox
but if you think about that the user could close the application while not connected
-
lovetox
now you suddenly have to save your not acked stanza cache to harddisk, and on resume you have to judge which of them make sense to send
-
MattJ
Yes, it's hard
-
lovetox
you have to take into account how much time passed
-
lovetox
probably offer UI to ask the user etc etc
-
lovetox
a lot of magic that can fail, and end in scenarios where the user just cant understand what and why something happend or didnt happen
-
lovetox
compare this with a very simple "You are not connected, so you cant do that right now"
-
lovetox
but as it seems, i cant even determine if im connected :D
-
pep.
I agree with lovetox that it's a lot of magic that can go wrong, (buffering and resending when connectivity gets back) :/
-
lovetox
for messages only i can imagine it, if i would have proper UI where i notify the user of messages that have not been sent last time, and he can choose to resend
-
lovetox
for everything else i would say not worth it
-
wurstsalat
sending messages while being offline would also satisfy a feature request :)
-
lovetox
yeah not a problem, but we need UI first that shows that a message has not reached the server, and after X minutes, dont send it anymore instead user has to manually issue a command to resend them
-
wurstsalat
we could use that info bar at the top of each chat control to inform + offer to try again (and mark unsent messages in the chat)
-
lovetox
yeah that sentence is a week worth of work :D
-
wurstsalat
sorry, just trying to point out a possible UI^^
-
wurstsalat
I always wanted to use that infobar for more :)