[
https://issues.apache.org/jira/browse/CB-12387?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15934730#comment-15934730
]
Alexandre commented on CB-12387:
--------------------------------
Hey!
Sorry I was busy last weeks :-( Ok so, I'm using Linux and android emulation
for developpement and Android 4.4.2 on tablet for production.
whitelisting websocket.org ? I don't use any black/white lists since I'm using
CSP:
<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 *;">
> android websocket can't connect anymore
> ---------------------------------------
>
> Key: CB-12387
> URL: https://issues.apache.org/jira/browse/CB-12387
> Project: Apache Cordova
> Issue Type: Bug
> Components: Android
> Environment: Linux
> Reporter: Alexandre
> Labels: websocket
>
> 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 [email protected],
> 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()
> {
> output = document.getElementById("output");
> testWebSocket();
> }
> function testWebSocket()
> {
> websocket = new WebSocket(wsUri);
> websocket.onopen = function(evt) { onOpen(evt) };
> websocket.onclose = function(evt) { onClose(evt) };
> websocket.onmessage = function(evt) { onMessage(evt) };
> websocket.onerror = function(evt) { onError(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>
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]