jdev - 2022-10-27


  1. cmb

    Am I high, or is XMPP over websockets arguably superior to XMPP over plain TCP, because XMPP over websockets has built-in framing?

  2. lovetox

    hm sounds slower, one websocket message can only have one stanza

  3. lovetox

    with tcp i can receive multiple stanzas in one read

  4. 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

  5. Zash

    Is "arguably superior" arguably subjective?

  6. Zash

    WebSockets also has that weirdo XOR encoding.

  7. moparisthebest

    lovetox, I mean that's just a different level right? one TCP read can give you multiple websocket messages with multiple stanzas too

  8. Zash

    WebSocket Messages can also be split into multiple frames, unless XMPP-over-WebSockets forbids that, and things enforce it...

  9. lovetox

    moparisthebest, yes i thought that as well, and it probably must be like that

  10. lovetox

    hmmm

  11. lovetox

    but would be weird or, like say you are a websocket lib and you call send(stanza)

  12. 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

  13. lovetox

    why would the tcp stack buffer that, and wait for "maybe something more comes i dont send this now"

  14. lovetox

    but i have no knowledge about tcp stuff, so my thinking is most likely wrong

  15. 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

  16. lovetox

    and who calls flush()? the tcp stack itself after some timeout?

  17. lovetox

    im just interested i dont know how this stuff works

  18. lovetox

    i just know, i never called flush() on any buffer ever, this was always abstracted away

  19. moparisthebest

    hmm I always end up calling flush() :/

  20. 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.

  21. cmb

    My read of RFC7395 is that frames correspond one to one with stanzas, so no splitting.

  22. 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.

  23. moparisthebest

    that's correct cmb

  24. moparisthebest

    also, what Sam said ^

  25. lovetox

    Sam, im pretty sure this is abstracted away

  26. lovetox

    if i use something like GLib, you have no access to any tcp buffers

  27. lovetox

    you have simple methods like write_async()

  28. lovetox

    and it gives you a callback when its done

  29. moparisthebest

    if the library abstracts it away then it's wasteful in some cases because it has to call flush() on every write

  30. Sam

    Hmm, yah, looks like Python doesn't let you be explicit about it? I dunno, just doing a quick look at the library

  31. moparisthebest

    but, it's an ok trade-off

  32. lovetox

    so what do you do? sounds like you also call flush() all the time :D

  33. lovetox

    or whats the other solution? add a milisecond timeout on every write, and wait for more data?

  34. moparisthebest

    I... call it when I need to

  35. moparisthebest

    sometimes I send a few stanzas and *then* call flush, sometimes after each stanza

  36. lovetox

    yeah but how to determine that you need to call flush after one stanza?

  37. lovetox

    i mean apart from obvious stuff like stream setup

  38. moparisthebest

    if I need it sent *now* I call flush

  39. 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?

  40. moparisthebest

    wait for something that needs sending now to come along

  41. moparisthebest

    you could set some type of timer I guess...

  42. lovetox

    ok and is a user written message stanza a category "needs sending now"?

  43. lovetox

    or only stuff like stream header , sasl responses etc

  44. moparisthebest

    I would say a user written message is "needs sending now"

  45. moparisthebest

    maybe like a read notification might not be ?

  46. lovetox

    you seem kind of vague, i thought you have written a lib that applies that logic

  47. lovetox

    or is that something which you leave to the application layer to decide

  48. moparisthebest

    well I haven't written an xmpp client yet :)

  49. lovetox

    ok, so back to websocket

  50. moparisthebest

    just a lot of networking code over the years

  51. 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

  52. lovetox

    it the worst case its just ip:5222

  53. lovetox

    do we have this for websocket?

  54. moparisthebest

    kinda, you just grab https://domain/.well-known/host-meta.json and connect to whatever that says

  55. lovetox

    so the xmpp server needs to run a http server

  56. moparisthebest

    websocket is already an http server

  57. moparisthebest

    but, yes

  58. lovetox

    websocket is probably also more complicated to setup if you want to serve a normal webpage on 443

  59. moparisthebest

    well it can be on any domain/port, doesn't *need* to be on the same one

  60. lovetox

    hm thats all that comes to mind for me

  61. lovetox

    on the client side, websocket is much easier

  62. lovetox

    like 1/3 of the code of normal tcp impl

  63. 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

  64. moparisthebest

    then you only need to grab that document and skip DNS, POSH etc