Tutorial
A tutorial is available for this demo at keaplogik.blogspot.com.
Frameworks
- Spring MVC
- Atmosphere Framework https://github.com/Atmosphere/atmosphere
- Twitter/Spring social https://github.com/SpringSource/spring-social
Purpose To demo an implementation of Websockets and Comet, when working with an existing SpringMVC web application.
This project was intended for testing on Tomcat 7.0.27 which was the only version of tomcat supporting websockets at the time this demo was created.
Configure your HTTP connector in Tomcat's conf/server.xml as such:
Not Required for versions of Tomcat greater than 7.0.27
<!-- Resolved an issue with http timeouts when using the tomcat comet adapter. Only an issue in Tomcat 7.0.27 -->
<Connector port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol"
connectionTimeout="600000"
redirectPort="8443" />
Other Notes
-
AJP protocol does not
currently
support websockets. -
The Http11NioProtocol does not work with atmosphere unless you have a context.xml in META-INF/context.xml in the following form. For Tomcat applications:
<?xml version="1.0" encoding="UTF-8"?> <Context> <Loader delegate="true"/> </Context>
I couldn't find a simple way to do this, but here it goes. I used STS.
Pull down project from github like so:
- go to File -> Import
- Select Git -> Projects from Git -> Click Next
- Select URI -> Click Next
- URI: https://github.com/keaplogik/springMVC-atmosphere-comet-websockets.git Host: github.com Click Next
- Click Next
- Specify destination -> Click Next
- Click Cancel
Now Import the project as a Maven Project like so:
- File -> Import
- Maven -> Existing Maven Projects -> Click Next
- In "Root Directory" Browse to this projects folder
- Click Finish
Now Add the Tomcat Server:
- In the Package Explorer -> Right click on Servers -> New -> Other
- Click Server-> Server -> Click Next
- Chooses Apache Tomcat 7.0 Server -> Click Next
- Browse to where you installed Tomcat 7.0.27 or newer -> Click Finish
- If you haven't downloaded Tomcat here is the link: http://apache.mirrors.tds.net/tomcat/tomcat-7/v7.0.34/bin/apache-tomcat-7.0.34.zip
Finally Run on the Tomcat server
- Right click on the project in the project explorer. Click Run as -> Run on Server
- Click the Tomcat Server, and click Finish.
And your up and running!