GitToTheHub commented on issue #1881:
URL:
https://github.com/apache/cordova-android/issues/1881#issuecomment-3914474495
Hi, this is not an issue because of cordova-android. Use `connect-src 'self'
https: wss:;` as CSP derictive. I tested the WebSocket connection and it
worked. Here is an example:
```js
ws.onopen = () => {
console.log('WebSocket connected:', wsUrl);
alert('WebSocket connected');
ws.send('ping from cordova');
};
ws.onmessage = (event) => {
console.log('WebSocket message:', event.data);
alert('WebSocket message: ' + event.data);
};
ws.onerror = (error) => {
console.log('WebSocket error:', JSON.stringify(error));
alert('WebSocket error: ' + JSON.stringify(error));
};
ws.onclose = (event) => {
console.log('WebSocket closed:', event.code, event.reason);
alert('WebSocket closed: ' + event.code + ' ' + event.reason);
};
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]