Check the user of a SockJS request

Issue: SPR-12497
(backport of commit dc5b5c)
Synchronize message sending

Issue: SPR-12516
(backport for commit b796c1)