I can see that stateful protocols lead to less botched together ’emulated state’ like cookies.
but testing becomes a lot harder to ensure that your implementation is correct and reconnects, and session continuations can be very hard to handle.
Is it considered better practice to always use stateless protocols, or is it really domain specific?
I think that authentication becomes easier when dealing with stateful protocols, but are there any other reasons you should use a stateful protocol?
How important is state to your application? Do you need a constant flow of data between different machines or is it more useful to have bursts? If you’re writing an IP Telephony type application then you’re probably going to want something fairly stateful, if you can get away with stateless it’s likely to be cheaper and easier to do it that way. Doing things statefully is necessarily more fragile because if either end of the connection gets dropped or the connection itself goes down you run a higher risk of data loss, whereas with a stateless connection you are more likely just to have to wait for a while and try again.
They really are different tools for different jobs, but given the ease and ubiquity of stateless technologies online it’s logical to look in that direction when you have the option.