What is the difference between WebSocket and STOMP protocols?

LancerSung picture LancerSung · Dec 6, 2016 · Viewed 39.2k times · Source

What are the major differences between WebSocket and STOMP protocols?

Answer

Nitin Kamate picture Nitin Kamate · Dec 22, 2016

This question is similar to asking the difference between TCP and HTTP. I shall still try to address your question, its natural to get confused between these two terms if you are beginning.

Short Answer

STOMP is derived on top of WebSockets. STOMP just mentions a few specific ways on how the message frames are exchanged between the client and the server using WebSockets.


Long Answer

WebSockets

It is a specification to allow synchronous bidirectional communication between a client and a server. While similar to TCP sockets, it is a protocol that operates as an upgraded HTTP connection, exchanging variable-length frames between the two parties, instead of a stream.

STOMP

It defines a protocol for clients and servers to communicate with messaging semantics. It does not define any implementation details, but rather addresses an easy-to-implement wire protocol for messaging integrations. It provides higher semantics on top of the WebSockets protocol and defines a handful of frame types that are mapped onto WebSockets frames. Some of these types are...

  • connect
  • subscribe
  • unsubscribe
  • send (messages sent to the server)
  • message (for messages send from the server) BEGIN, COMMIT, ROLLBACK (transaction management)