Jump to content

Recommended Posts

Posted

Hi

How is possible to make the websocket connection as wss and not ws.

I am using caddy for https connection.

I get the following error on browser.

Mixed Content: The page at 'https://xxxx.portal.xxxx.co/' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint 'ws://xxxx.portal.xxxxx.co/uniWebSocket/_S_ID='1_E82935bhQd111F851D4'&_app='uniguixxx_exe''. This request has been blocked; this endpoint must be available over WSS.

 

Uncaught SecurityError: Failed to construct 'WebSocket': An insecure WebSocket connection may not be initiated from a page loaded over HTTPS.
    at Object.createSocket (ext-unicommon-min.js:9:3242)
    at Object.openSocket (ext-unicommon-min.js:9:2108)
    at Object.timerHandle (ext-unicommon-min.js:9:2511)
    at ext-unicommon-min.js:9:2248

 Regards

Posted

Hi

I found a solution to this issue.

To make the websocket work as WSS add the followimg Javascript to you main form

 

function window.afterrender(sender, eOpts)
{
// Force WebSocket to use WSS when site is under HTTPS
if (location.protocol === 'https:') {
  var oldCreateSocket = ajaxRequest.createSocket;
  ajaxRequest.createSocket = function(url) {
    if (url.startsWith('ws://')) {
      url = url.replace('ws://', 'wss://');
    }
    return oldCreateSocket.call(this, url);
  };
}

}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...