Hi Sabra,

Did you check the Context path is correct? Also can you check what is the
error code that you get?
Thanks

On Thu, Jun 25, 2015 at 4:28 PM, Sabra Ossen <sabra...@gmail.com> wrote:

> Hi,
>
> I am following the blog mentioned in [1] and I can successfully run the
> Web App in the local tomcat server, when I run the following code in the
> WSO2 AS 5.3.0 alpha the browser returns the following error in the browser
> console.
>
> *Firefox can't establish a connection to the server at
> ws://10.225.125.91:9763/TestWebApp/echo
> <http://10.225.125.91:9763/TestWebApp/echo>.*
>
> Server code;
>
> import java.io.IOException;
>  import javax.websocket.OnClose;import javax.websocket.OnMessage;import 
> javax.websocket.OnOpen;import javax.websocket.Session;import 
> javax.websocket.server.ServerEndpoint;
>
> @ServerEndpoint("/echo") public class EchoServer {
>
>     @OnOpen
>     public void onOpen(Session session){
>         System.out.println(session.getId() + " has opened a connection");
>         try {
>             session.getBasicRemote().sendText("Connection Established");
>         } catch (IOException ex) {
>             ex.printStackTrace();
>         }
>     }
>
>     @OnMessage
>     public void onMessage(String message, Session session){
>         System.out.println("Message from " + session.getId() + ": " + 
> message);
>         try {
>             session.getBasicRemote().sendText(message);
>         } catch (IOException ex) {
>             ex.printStackTrace();
>         }
>     }
>
>     @OnClose
>     public void onClose(Session session){
>         System.out.println("Session " +session.getId()+" has ended");
>     }}
>
>
> index.html;
>
> <!DOCTYPE html>
>
> <html>
>     <head>
>         <title>Echo Chamber</title>
>         <meta charset="UTF-8">
>         <meta name="viewport" content="width=device-width">
>     </head>
>     <body>
>
>         <div>
>             <input type="text" id="messageinput"/>
>         </div>
>         <div>
>             <button type="button" onclick="openSocket();" >Open</button>
>             <button type="button" onclick="send();" >Send</button>
>             <button type="button" onclick="closeSocket();" >Close</button>
>         </div>
>         <!-- Server responses get written here -->
>         <div id="messages"></div>
>
>         <!-- Script to utilise the WebSocket -->
>         <script type="text/javascript">
>
>             var webSocket;
>             var messages = document.getElementById("messages");
>
>             function openSocket(){
>
>                 if(webSocket !== undefined && webSocket.readyState !==
> WebSocket.CLOSED){
>                    writeResponse("WebSocket is already opened.");
>                     return;
>                 }
>
>                 *webSocket = new WebSocket("ws://" + window.location.host
> + "/TestWebApp/echo");*
>
>                 webSocket.onopen = function(event){
>                         if(event.data === undefined)
>                         return;
>
>                     writeResponse(event.data);
>                 };
>
>                 webSocket.onmessage = function(event){
>                     writeResponse(event.data);
>                 };
>
>                 webSocket.onclose = function(event){
>                     writeResponse("Connection closed");
>                 };
>             }
>
>             function send(){
>                 var text = document.getElementById("messageinput").value;
>                 webSocket.send(text);
>             }
>
>             function closeSocket(){
>                 webSocket.close();
>             }
>
>             function writeResponse(text){
>                 messages.innerHTML += "<br/>" + text;
>             }
>
>         </script>
>
>     </body>
> </html>
>
> Is their any particular way that the web socket is defined within the AS.
> Can anyone help me with this issue. Thanks in advance.
>
> [1] https://blog.idrsolutions.com/2013/12/websockets-an-introduction/
>
> Regards.
>
> --
> Sabra Ossen <http://lk.linkedin.com/in/sabraossen>
> Undergraduate | Department of Computer Science and Engineering
> University of Moratuwa
> Sri Lanka
>
> _______________________________________________
> Dev mailing list
> Dev@wso2.org
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>


-- 
Thusitha Dayaratne
Software Engineer
WSO2 Inc. - lean . enterprise . middleware |  wso2.com

Mobile  +94712756809
Blog      alokayasoya.blogspot.com
About    http://about.me/thusithathilina
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to