-
cmb
Am I high, or is XMPP over websockets arguably superior to XMPP over plain TCP, because XMPP over websockets has built-in framing?
-
lovetox
hm sounds slower, one websocket message can only have one stanza
-
lovetox
with tcp i can receive multiple stanzas in one read
-
moparisthebest
you could make that argument, I'd argue XMPP 2.0 should add explicit stanza framing, it's been the source of many bugs, some security issues, and I see no downsides
-
Zash
Is "arguably superior" arguably subjective?
-
Zash
WebSockets also has that weirdo XOR encoding.
-
moparisthebest
lovetox, I mean that's just a different level right? one TCP read can give you multiple websocket messages with multiple stanzas too
-
Zash
WebSocket Messages can also be split into multiple frames, unless XMPP-over-WebSockets forbids that, and things enforce it...
-
lovetox
moparisthebest, yes i thought that as well, and it probably must be like that
-
lovetox
hmmm
-
lovetox
but would be weird or, like say you are a websocket lib and you call send(stanza)
-
moparisthebest
to be clear I'm saying I think framing is good, and that we *could* have it at the TCP/QUIC level, if we wanted it
-
lovetox
why would the tcp stack buffer that, and wait for "maybe something more comes i dont send this now"
-
lovetox
but i have no knowledge about tcp stuff, so my thinking is most likely wrong
-
moparisthebest
lovetox, most everything ends up writing to a buffered writer that doesn't flush until it's full or flush() is called, including websocket libs
-
lovetox
and who calls flush()? the tcp stack itself after some timeout?
-
lovetox
im just interested i dont know how this stuff works
-
lovetox
i just know, i never called flush() on any buffer ever, this was always abstracted away
-
moparisthebest
hmm I always end up calling flush() :/
-
Sam
I suspect that's a source of bugs if you never call flush. You might be calling other operations that implicitly call flush, but I doubt your TCP stack is doing it for you.
-
cmb
My read of RFC7395 is that frames correspond one to one with stanzas, so no splitting.
-
Sam
Or things are only being flushed once the buffer is full and they might sit there for a while if nobody is sending anything. There may be enough random traffic from various presences and the like that you've just never noticed it, but in theory you could suddenly have nothing sent because you're not caling flush anywhere.
-
moparisthebest
that's correct cmb
-
moparisthebest
also, what Sam said ^
-
lovetox
Sam, im pretty sure this is abstracted away
-
lovetox
if i use something like GLib, you have no access to any tcp buffers
-
lovetox
you have simple methods like write_async()
-
lovetox
and it gives you a callback when its done
-
moparisthebest
if the library abstracts it away then it's wasteful in some cases because it has to call flush() on every write
-
Sam
Hmm, yah, looks like Python doesn't let you be explicit about it? I dunno, just doing a quick look at the library
-
moparisthebest
but, it's an ok trade-off
-
lovetox
so what do you do? sounds like you also call flush() all the time :D
-
lovetox
or whats the other solution? add a milisecond timeout on every write, and wait for more data?
-
moparisthebest
I... call it when I need to
-
moparisthebest
sometimes I send a few stanzas and *then* call flush, sometimes after each stanza
-
lovetox
yeah but how to determine that you need to call flush after one stanza?
-
lovetox
i mean apart from obvious stuff like stream setup
-
moparisthebest
if I need it sent *now* I call flush
-
lovetox
ok and if you dont need to send it now? you wait for something that needs sending now? or you wait a certain time?
-
moparisthebest
wait for something that needs sending now to come along
-
moparisthebest
you could set some type of timer I guess...
-
lovetox
ok and is a user written message stanza a category "needs sending now"?
-
lovetox
or only stuff like stream header , sasl responses etc
-
moparisthebest
I would say a user written message is "needs sending now"
-
moparisthebest
maybe like a read notification might not be ?
-
lovetox
you seem kind of vague, i thought you have written a lib that applies that logic
-
lovetox
or is that something which you leave to the application layer to decide
-
moparisthebest
well I haven't written an xmpp client yet :)
-
lovetox
ok, so back to websocket
-
moparisthebest
just a lot of networking code over the years
-
lovetox
what i like about the standard tcp connection way is, that i dont need dns or any other mechanism to connect to the server
-
lovetox
it the worst case its just ip:5222
-
lovetox
do we have this for websocket?
-
moparisthebest
kinda, you just grab https://domain/.well-known/host-meta.json and connect to whatever that says
-
lovetox
so the xmpp server needs to run a http server
-
moparisthebest
websocket is already an http server
-
moparisthebest
but, yes
-
lovetox
websocket is probably also more complicated to setup if you want to serve a normal webpage on 443
-
moparisthebest
well it can be on any domain/port, doesn't *need* to be on the same one
-
lovetox
hm thats all that comes to mind for me
-
lovetox
on the client side, websocket is much easier
-
lovetox
like 1/3 of the code of normal tcp impl
-
moparisthebest
FYI I'll soon write a XEP to expand host-meta.json to support Direct TLS, QUIC, pinned-public-keys, encrypted-client-hello, etc https://github.com/moparisthebest/xmpp-proxy/blob/master/contrib/host-meta/xep-0156-proposed-minimal.json
-
moparisthebest
then you only need to grab that document and skip DNS, POSH etc