In my jsp file I have
<script type="text/javascript" src="/resources/scripts/jWebSocket.js"></script>
<script type="text/javascript">
//jws.browserSupportsWebSockets checks if web sockets are available
//either natively, by the FlashBridge or by the ChromeFrame.
if( jws.browserSupportsWebSockets() ) {
jWebSocketClient = new jws.jWebSocketJSONClient();
// Optionally enable GUI controls here
} else {
// Optionally disable GUI controls here
var lMsg = jws.MSG_WS_NOT_SUPPORTED;
alert(lMsg);
}
var lURL = jws.getDefaultSSLServerURL() + "/;timeout=360000";
alert(lURL);
/* var lRes = jWebSocketClient.broadcastText(
"", // broadcast to all clients (not limited to a certain pool)
lMsg // broadcast this message
);
alert(lRes.code);
*/
function broadcast() {
var lMsg = "This is test message";
var lTarget = "*";
if( lMsg.length > 0 ) {
//log( USR, OUT, lMsg );
var lRes;
if( !lTarget || lTarget == "*") {
alert(lMsg);
lRes = jWebSocketClient.broadcastText(
"", // broadcast to all clients (not limited to a certain pool)
lMsg // broadcast this message
);
} else {
lRes = jWebSocketClient.sendText(
lTarget, // broadcast to all clients (not limited to a certain pool)
lMsg // broadcast this message
);
}
// log error only, on success don't confuse the user
if( lRes.code != 0 ) {
alert(lRes.msg);
//log( SYS, OUT, "broadcast: " + lRes.msg );
}
// eMessage.value = "";
}
//doFocus( eMessage );
}
</script>
It does not go to else part of this if( jws.browserSupportsWebSockets() ). it means browser supports websockets.
At last it goes to if( lRes.code != 0 ) and alert “Not connected”
Am I missing something. Please help
In my terminal window I am getting this message
TCPEngine: SSL engine 'tcp0' started' at port 9797 with default timeout infinite.
2012-08-15 09:52:45,979 DEBUG - JWebSocketFactory: Starting servers...
2012-08-15 09:52:45,980 INFO - TokenServer: Token server 'ts0' started.
2012-08-15 09:52:45,980 INFO - JWebSocketFactory: jWebSocket server startup complete
it means server is running.
When I alert lURL from below code
var lURL = jws.getDefaultSSLServerURL() + "/;timeout=360000"; in my jsp file.
it prints
wss://localhost:9797/jWebSocket/jWebSocket/;timeout=360000
Yes. You are missing the logon call. Add the following lines (instead of where your
alert(lUrl)is):the first
"guest"is username and the second is password. if you haven’t changed yet the jwebsocket.conf file in your server, than there should be a user with these credentials.let know if this helps