Hi Sabra,

Since you are using JSR 356 based implementation it is not working on the
AS 5.2.1. Because AS 5.2.1 only supports tomcat based websocket
implementation. But sample should be worked on AS 5.3.0-Alpha. Are you
building this using a maven project? If so share the pom.

Thanks

On Fri, Jun 26, 2015 at 8:32 PM, Sabra Ossen <sabra...@gmail.com> wrote:

> Hi,
>
> @Chathura, I am using oracle JDK 7 in Ubuntu 14.04.
>
> @Manoj, Thank you for the samples. But this particular example does not
> work in the AS 5.3.0 as well as 5.2.1. The built in samples work well in
> both versions of the AS.
>
> Regards.
>
> On Fri, Jun 26, 2015 at 4:57 PM, Chathura Priyankara <chathu...@wso2.com>
> wrote:
>
>> Hi Sabra,
>>
>> I was able to run the same sample successfully in AS 5.3.0 running on
>> Ubuntu machine. I'm using JDK 7.
>> Could you please mention the JDK version and OS that you are using ?
>>
>> Regards,
>> Chathura.
>>
>> On Fri, Jun 26, 2015 at 3:55 PM, Sabra Ossen <sabra...@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> @Thusitha , there are no extra jars in the web app and also is there is
>>> method to check out the actual web socket that gets deployed in the AS.
>>>
>>> @Kasun, the name of the web app is the same "TestWebApp" and I checked
>>> the behavior in chrome which displays the following error in the console
>>>
>>>
>>> *Failed to load resource: the server responded with a status of 405
>>> (Method Not Allowed)WebSocket connection to
>>> 'ws://10.224.29.52:9763/TestWebApp/echo
>>> <http://10.224.29.52:9763/TestWebApp/echo>' failed: Error during WebSocket
>>> handshake: Unexpected response code: 404*
>>>
>>> Regards.
>>>
>>> On Thu, Jun 25, 2015 at 6:55 PM, KasunG Gajasinghe <kas...@wso2.com>
>>> wrote:
>>>
>>>> Hi,
>>>>
>>>> What's the war name of your webapp? AS do not process the path
>>>> parameter in context.xml currently. Rather, it uses the war name as the
>>>> context.
>>>>
>>>> Also, you might want to run the same in Chome and verify the behavior.
>>>> In some of the Firefox versions, you need to use MozWebSocket object
>>>> instead of WebSocket object. See [1].
>>>>
>>>> [1]
>>>> https://github.com/wso2/product-as/blob/master/modules/samples/example/src/main/resources/websocket/chat.xhtml#L55
>>>>
>>>> On Thu, Jun 25, 2015 at 5:38 PM, Thusitha Thilina Dayaratne <
>>>> thusit...@wso2.com> wrote:
>>>>
>>>>> Hi Sabra,
>>>>>
>>>>> AFAIK you don't have to do any extra configurations to make websocket
>>>>> works with AS. This kind of issues may pop out when webapp contains
>>>>> websoket jars inside the webapp itself (WEB-INF/lib).
>>>>> IF not most probably there is some mismatch in the actual websocket
>>>>> that get deployed and what you are trying to connect.
>>>>>
>>>>> Thanks
>>>>>
>>>>> On Thu, Jun 25, 2015 at 5:08 PM, Sabra Ossen <sabra...@gmail.com>
>>>>> wrote:
>>>>>
>>>>>> Hi Thusitha,
>>>>>>
>>>>>> The context path is as follows (present in context.xml),  *<Context
>>>>>> antiJARLocking="true" path="/TestWebApp"/>*
>>>>>>
>>>>>> and the error code is 404 stating that the html file "echo" was not
>>>>>> found.
>>>>>>
>>>>>> Thanks.
>>>>>>
>>>>>> On Thu, Jun 25, 2015 at 4:43 PM, Thusitha Thilina Dayaratne <
>>>>>> thusit...@wso2.com> wrote:
>>>>>>
>>>>>>> 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
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Sabra Ossen <http://lk.linkedin.com/in/sabraossen>
>>>>>> Undergraduate | Department of Computer Science and Engineering
>>>>>> University of Moratuwa
>>>>>> Sri Lanka
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> 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
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>>
>>>> *Kasun Gajasinghe*Senior Software Engineer, WSO2 Inc.
>>>> email: kasung AT spamfree wso2.com
>>>> linked-in: http://lk.linkedin.com/in/gajasinghe
>>>> blog: http://kasunbg.org
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> 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
>>>
>>>
>>
>>
>> --
>> Chathura Priyankara
>> Software Engineer | WSO2 Inc.
>> Mobile : +94718795340
>> Blog : www.codeoncloud.blogspot.com
>>
>
>
>
> --
> 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