Hi Tanya,

according to my understanding this is not an issue with Jaggery but the web
socket specification. Since it is intended to provide two-way communication
with a remote host the connection should be persistent.

According to [1] "WebSocket connections do not, however, persist across
loading of new pages from the same domain, or page reloads. A WebSocket
connection only persists as long as the page is still open (not navigated
away from)."

The initial code snippet call the same page this might be the issue that
breaks the code.

[1] http://tavendo.com/blog/post/websocket-persistent-connections/

Regards,
Malith

On Fri, Mar 27, 2015 at 6:52 PM, Tanya Madurapperuma <[email protected]> wrote:

> Hi all,
>
> Do we allow $ Subject?
> I tried the below snippet in a file called index.jag. But it breaks
> silently.
>
> <!DOCTYPE html>
> <%
> var log = new Log();
> WebSocket.ontext = function (data) {
>  log.info('data sent '+ data)
> };
> %>
> <html>
> <head>
> <meta charset="UTF-8">
> <title>Jaggery WebSocket</title>
> <script type="text/javascript">
>  var ws = new WebSocket(
>    "ws://localhost:9763/web/index.jag");
>
>  function sendMessage() {
>   ws.send(messageText.value);
>   messageText.value = "";
>  }
> </script>
> </head>
> <body>
> <div>
>   <br>
>   <input type="text" id="messageText" size="50" />
>   <input id="button1" type="button" value="Send" onclick="sendMessage();">
> </div>
> </body>
> </html>
>
> But if I move the below snippet to a different file called server.jag and
> change the web socket url to ws://localhost:9763/web/server.jag, it works
> fine.
>
> <%
> var log = new Log();
> webSocket.ontext = function (data) {
>  log.info('data sent '+ data)
> };
> %>
>
> I understand it doesn't make sense to call the same page. But just asking
> :)
>
> Thanks,
> Tanya
>
> --
> Tanya Madurapperuma
>
> Software Engineer,
> WSO2 Inc. : wso2.com
> Mobile : +94718184439
> Blog : http://tanyamadurapperuma.blogspot.com
>
> _______________________________________________
> Dev mailing list
> [email protected]
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>


-- 
Malith Munasinghe | Software Engineer
M: +94 (071) 9401122
E: [email protected]
W: http://wso2.com
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to