Java WebSocket 1.1 working with Grails Tomcat7 OK, NOT bootrun

186 прегледи
Прескокни до првата непрочитана порака

Anders Kristian Andersen

непрочитано,
22.4.2015, во 05:48:1222.4.15
до grails-de...@googlegroups.com
Hi

I have migrated the Tomcat sample EchoAnnotation to my Grails 3.0.1 helloworld.

It works fine via war --> tomcat 7 deployment

Statement:
@ServerEndpoint("/websocket/echoAnnotation")

does the work.
Javascript clients can use url "ws://localhost:8080/helloworld/websocket/echoAnnotation"

But from gradle bootrun it does not work
It gives code 1006

I observe 2 things
a) javax.websocket:javax.websocket-api:1.1 is NOT needed as a dependency in Grails. This means that the classes is onboard Grails.
When I did a test outside Grails on a pure gradle war project I found out that javax.websocket:javax.websocket-api must NEVER be in WEB-INF/lib
The would cause code 1006 as well.

b) bootRun must some how respect @ServerEndpoint("/websocket/echoAnnotation").
And I think that I probably have to add some thing some where ???

Anders Kristian Andersen

непрочитано,
26.4.2015, во 05:12:4026.4.15
до grails-de...@googlegroups.com
I think I have solved how to add support for web-socket.
My first approach was using the raw Java WebSocket 1.1 API defined by JSR-356
But this seems to be a little implementation specific to Tomcat/Jetty etc.

Therefore I have change approach to using Spring-Websocket.
Hereby Spring solves the problem of dealing with the right implementation of Web-Socket 
Spring web socket support also enables more sophisticated protocols.

(the code sample from here works fine...)

There is one issue
Grails application.groovy 
must have added @ComponentScan("helloworld")
Then it starts to work...
And the spring controllers cannot be located in grails-app/controllers/helloworld....
This gives a duplicate Request mapping.
This is another issue. (to be discussed somewhere else)



Vahid Hedayati

непрочитано,
29.4.2015, во 11:08:2229.4.15
до grails-de...@googlegroups.com
Hey Anders

I have created a demo project here:


https://github.com/vahidhedayati/testwebsocket-grails3

This does a basic echo test between front/back end. It is all working too...


From what I understand neither of these i.e. your post and this post are the real answer to the actual question in subject and I doubt there is a real fix for those wish to remain with the default tomcat websocket.

At this rate for me to migrate my default websocket plugins, would really mean a rewrite to use spring websocket...


https://github.com/spring-projects/spring-boot/blob/master/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/echo/EchoWebSocketHandler.java  as the folder states websocket-tomcat but the java files are nothing like a default tomcat websocket. Maybe this is for sockets running under tomcat rather than default tomcat websockets..


Confused yet join the club :)
Одговор до сите
Одговорете му на авторот
Проследи
0 нови пораки