9

Have someone tried to make a friendship between socket.io and spring mvc? I've found many examples with using of sockJS over Stomp and no examples of socket.io.

  • Haven't seen one for Spring MVC directly, but here's an external link to one for Java EE. Could also be out of date, but it probably wouldn't be terribly difficult to adapt it for Spring: https://oneminutedistraction.wordpress.com/2013/08/12/marrying-socket-io-client-with-java-ee-7s-websocket/ – riddle_me_this Nov 08 '16 at 19:13
  • why not just have separate nodejs + express + socket.io app? – num8er Nov 09 '16 at 14:47
  • Are you trying to work with the websocket server that you've written in node.js Socket.io with Spring? Please confirm this so I can help. – user3254198 Nov 10 '16 at 03:28
  • Yes! You are correct user3254198. That is exactly what I am trying to do. – Rolando Nov 10 '16 at 15:16
  • 2
    Guys, after researching, i've stoped my attempts to integrate Socket.IO to Spring, i've tried Atmosphere framework but it works only with low level Socket.Io protocol. Answering question above: I'am working with standard servlet container(tomcat) with springMVC and my websocket connection constructing in view rendered by java framework thymeleaf. So, after writing some prototypes, i came to sockjs without STOMP protocol, cause i have to support mobile clients too. And everything works fine, in web i have sockjs lib, in mobile(WIN,IOS,ANDROID) clients native websockets. – Aleksander Melnichnikov Nov 15 '16 at 09:50
  • @AleksanderMelnichnikov , which sub protocol did you end up using? I'm close to ditching STOMP altogether and use a JSON based messaging approach. Any comments are appreciated. Thanks! – Jesús Zazueta Aug 21 '17 at 23:18
  • @JesúsZazueta Hello! I created webchat, so I didn't use any sub protocol as STOMP. I created my own JSON based chat pseudo protocol. But if you want to make web-application which use websockets instead standard HTTP approach - STOMP will be great(cause it's like HTTP and you can route ws messages to specific handlers). So, the answer will be: it depends of what you're going to implement. – Aleksander Melnichnikov Aug 21 '17 at 23:24
  • More precisely the question is in what do you want to implement or already implemented and what problems do you have now with STOMP? – Aleksander Melnichnikov Aug 21 '17 at 23:47
  • @AleksanderMelnichnikov , same use case: user chat. I was having some trouble with StompJS messages (generated in react native) getting processed incorrectly on the server side. iOS worked OK, but Android sent corrupt content. Traced the fault down to the fact that Android 7.0's web socket implementation dismissed the `null` character message terminator upon sending the raw data string. I was a sad panda for about 3 days. It's fixed now on the server side (hacky path). Thanks. – Jesús Zazueta Aug 25 '17 at 01:17
  • For a integration with spring maybe sockjs is better, [spring official sample](https://spring.io/guides/gs/messaging-stomp-websocket/) – deFreitas Jul 04 '18 at 16:24

0 Answers0