Websocket connetion fails on droplet with Ubuntu 14.04.
I created and tested a Java EE 7 application that uses WebSockets on my local PC. All works fine when I deploy to WildFly 8 on my local machine, and access the application using localhost.
When I deploy the same application on a cloud server, (Ubuntu 14.04) with exactly the same WildFly configuration, I get the following message when the application tries to connect:
"NetworkError: 404 Not Found - http://178.xx.xx.xx:8080/pss/ws/notification" Firefox can't establish a connection to the server at ws://178.xx.xx.xx:8080/pss/ws/notification.
I can access the application, it is just the websocket connection that fails.
pss is my context root, and the websocket end point is annotated with @ServerEndpoint(“/ws/notification”), so the URL is correct and works 100% on my local machine using localhost.
When I deploy the application I can see that the websocket endpoint has been picked up by WildFly, so this is not the issue
2015-02-14 14:18:21,200 INFO [io.undertow.websockets.jsr] (MSC service thread 1-2) UT026003: Adding annotated server endpoint class za.co.ssms.interfaces.websocket.NotificationWebSocket for path /ws/notification
The request headers are correct:
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Encoding gzip, deflate Accept-Language en-US,en;q=0.5 Cache-Control no-cache Connection keep-alive, Upgrade Cookie JSESSIONID=mgFhI1MAZwT2NwULXDXgEaXt.app Host 178.xx.xx.xx:8080 Origin http://178.xx.xx.xx:8080 Pragma no-cache Sec-WebSocket-Key LD55xYAKjJoXgLXQpUS7fA== Sec-WebSocket-Version 13 Upgrade websocket User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:35.0) Gecko/20100101 Firefox/35.0
I am accessing the application using the following URL (IP modified), and the ports match:
If I run netstat -an | grep ‘LISTEN’ on my cloud server I get the following, which shows that 0.0.0.0:8080 is bound and listening:
tcp 0 0 127.0.0.1:9990 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:3528 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:8787 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp6 0 0 :::22 :::* LISTEN unix 2 [ ACC ] STREAM LISTENING 9227 /var/run/acpid.socket unix 2 [ ACC ] STREAM LISTENING 7014 @/com/ubuntu/upstart unix 2 [ ACC ] STREAM LISTENING 8907 /var/run/dbus/system_bus_socket unix 2 [ ACC ] STREAM LISTENING 9448 /var/run/mysqld/mysqld.sock unix 2 [ ACC ] SEQPACKET LISTENING 7666 /run/udev/control
Apache is not installed so this is a direct connection to WildFly server.
After several days I am pretty stumped as to why this is failing.
Somewhere in the chain the HTTP upgrade requests that are failing, and I can not pin point where.
Thanks in advance
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.×