Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Incomplete
-
None
-
None
-
Linux
-
Important
Description
Hi!
Since my latest cordova update(6.5.0) I can't connect to my local websocket server. I've tried with echo.websocket.org without any success too. All is ok with "cordova run browser". Don't know where's problem(i've tried to downgrade but no success anymore...).
EDIT:after many tries, websocket don't works with android android@6.1.1, succes works with android 5
Sample code:
<!DOCTYPE html>
<meta charset="UTF-8">
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'; img-src * data: 'unsafe-inline'; connect-src * 'unsafe-inline'; frame-src *;">
<meta name="format-detection" content="telephone=no">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/cordova_init.js"></script>
<title>WebSocket Test</title>
<script language="javascript" type="text/javascript">
var wsUri = "ws://echo.websocket.org/";
var output;
function init()
function testWebSocket()
{
websocket = new WebSocket(wsUri);
websocket.onopen = function(evt)
;
websocket.onclose = function(evt)
;
websocket.onmessage = function(evt)
;
websocket.onerror = function(evt)
;
}
function onOpen(evt)
{ writeToScreen("CONNECTED"); doSend("WebSocket rocks"); }function onClose(evt)
{ writeToScreen("DISCONNECTED"); }function onMessage(evt)
{ writeToScreen('<span style="color: blue;">RESPONSE: ' + evt.data+'</span>'); websocket.close(); }function onError(evt)
{ writeToScreen('<span style="color: red;">ERROR:</span> ' + evt.data); }function doSend(message)
{ writeToScreen("SENT: " + message); websocket.send(message); }function writeToScreen(message)
{ var pre = document.createElement("p"); pre.style.wordWrap = "break-word"; pre.innerHTML = message; output.appendChild(pre); }window.addEventListener("load", init, false);
</script>
<h2>WebSocket Test</h2>
<div id="output"></div>