Jump to content

Recommended Posts

Posted

Hi,

I am using HyperServer for WebSockets in unigui a dedicated service.  Say on port 8078 (https)

I need to find an example of sending a broadcast outside of UniGUI......

is there any documentation for this,   the end result will be

I want to perform a call to the HyperServer from c# passing the data/token etc... which then broadcasts to all the clients........

Can someone provide documentation for this ?

 

Thanks.

 

 

  • Administrators
Posted

Hi, 

For this you don't need to use websockets. Simply make a http call to the server and handle it in one of the nodes. (the persistent node preferably ) then broadcast the message to unigui sessions. 

Posted

On a slightly different tack.

I am using CloudFlare to manage a UniGUI Server (it handles all SSL functionality) but now find that WebSockets no longer work. To me it appears to be a port issue.

Has anyone dealt with this in the past ?

Posted
On 20/01/2026 at 15:42, andyhill said:

Em uma abordagem um pouco diferente.

Estou usando o CloudFlare para gerenciar um servidor UniGUI (ele gerencia toda a funcionalidade SSL), mas agora percebo que os WebSockets não funcionam mais. Para mim, parece ser um problema de porta.

Alguém já passou por isso antes?

Many people dream of running their web service with Cloudflare.

Your web service needs to be WSS (Web Service Server) to receive website access.

Posted

Further investigation: UniGUI Server will not enable Websockets if UniGUI Server is not in SSL Mode on startup !

Farshad, one of the enticements to come over to CloudFlare is that ALL communication between the outside world and UniGUI Server is handled by CloudFlare's SSL routing, not by UniGUI Server - thus no more expensive local SSL certificates (we now use CloudFlare's certificate) - hooray.

That means we run our UniGUI Server on IP 127.0.0.1 port 8xxx AND CloudFlare takes over by redirecting and Encrypting / Decrypting ALL outside traffic via their own SSL tunnel to our nominated port.

Can we have a UniGUI Server option override to force Websockets to be enabled on port 8xxx with no UniGUI Server SSL please.

Posted

Farshad, I know you are busy but it would help if you could acknowledge my problem and indicate if there will be a future solution ? 

Thanks in advance.

  • Administrators
Posted
18 hours ago, andyhill said:

Farshad, I know you are busy but it would help if you could acknowledge my problem and indicate if there will be a future solution ? 

Thanks in advance.

Hi Andy,

What is your deployment method?

Which method is used to enable Websockets? 

Posted

Yes, but UniGUI Server will not enable WebSockets UNLESS SSL IS ENABLED WITHIN UNIGUI SERVER.

Under CloudFlare we do not use UniGUI Server's SSL bindings.

As stated earlier we need to enable WebSockets on UniGUI Server without SSL.

  • Administrators
Posted
On 2/1/2026 at 9:27 PM, andyhill said:

Yes, but UniGUI Server will not enable WebSockets UNLESS SSL IS ENABLED WITHIN UNIGUI SERVER.

Under CloudFlare we do not use UniGUI Server's SSL bindings.

As stated earlier we need to enable WebSockets on UniGUI Server without SSL.

OK. We will investigate this situation.

Posted

Hi

I have the same issue, I believe what is required that Unigui send "WSS" not "WS", I believe this will resolve the issue. I tried using JavaScript to change the "WS" to "WSS" but it looks that Unigui ignores and send "WS".

If this is resolved it will be a massive help.

 

Regards

Posted

Hi 

Using Caddy, ssl works with Unigui App without any issue except the WebSocket. 

I believe, Caddy expect Unigui WebSocket to be prefixed with "WSS" not "WS" and ssl will work.

Is it possible to have "WSS" prefix?

Regards

 

Posted

This is the error message we get 

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

Unfortunately this is very critical on our project and has stopped our development. 

We have tried various JS and Caddy hacks with no results.

We be very grateful if somehow this issue is resolved.

Posted

If you have websocket ssl issue, use the following JS. 

Place it in a file and load it to customfiles. It is working with Caddy now.

Farshad it would be very helpful if you have a look and see this is OK to use.


UniServerModule.CustomFiles.Add('files/wsfix.js');


// wsfix.js
(function () {
  if (window.__wsfix_installed) return;
  window.__wsfix_installed = true;

  // Only when the page is HTTPS
  if (location.protocol !== "https:") return;

  // Keep reference to the real WebSocket (avoid double-wrapping)
  var RealWebSocket = window.WebSocket;
  if (!RealWebSocket) return;

  window.WebSocket = function (url, protocols) {
    try {
      if (typeof url === "string" && url.indexOf("ws://") === 0) {
        url = "wss://" + url.substring(5);
      }
    } catch (e) {}

    // constructor behavior
    return protocols !== undefined
      ? new RealWebSocket(url, protocols)
      : new RealWebSocket(url);
  };

  // preserve constants (OPEN, CLOSED, etc.)
  window.WebSocket.prototype = RealWebSocket.prototype;
  Object.keys(RealWebSocket).forEach(function (k) {
    try { window.WebSocket[k] = RealWebSocket[k]; } catch (e) {}
  });
})();

  • Upvote 1
  • 1 month later...
Posted

Hi Farshad, Some time ago I mentioned that stand alone UniGUI applications will not engage WebSocket mode when they are not binding a SSL Certificate which makes sense if the application is handling SSL itself.

BUT when run in a CloudFlare environment the UniGUI application must not engage SSL mode because CloudFlare looks after all http and https traffic (using their own SSL Certificate) removing the need for the application to have a SSL Certificate or run in SSL mode - the end result is that the application is fed the web stream to ONE IP and ONE PORT in either http or https (port switching is managed by CloudFlare and tunneled back to port 80 no matter what mode). 

Simply put we need the UniGUI application to enable WebSocket mode without the need of a SSL Certificate.

You said "OK. We will investigate this situation"

Has this been resolved ?

Kind Regards
Andy

  • Administrators
Posted
10 hours ago, andyhill said:

Hi Farshad, Some time ago I mentioned that stand alone UniGUI applications will not engage WebSocket mode when they are not binding a SSL Certificate which makes sense if the application is handling SSL itself.

BUT when run in a CloudFlare environment the UniGUI application must not engage SSL mode because CloudFlare looks after all http and https traffic (using their own SSL Certificate) removing the need for the application to have a SSL Certificate or run in SSL mode - the end result is that the application is fed the web stream to ONE IP and ONE PORT in either http or https (port switching is managed by CloudFlare and tunneled back to port 80 no matter what mode). 

Simply put we need the UniGUI application to enable WebSocket mode without the need of a SSL Certificate.

You said "OK. We will investigate this situation"

Has this been resolved ?

Kind Regards
Andy

Hi,

So let me understand the situation better. 

Your app runs behind cloudflare. Cloudflare handles https calls and redirect calls to your app using a http channel? What is your particular setup?

Can you explain the exact way that cloudflare handles calls and directs them to your server?

Posted

I have explained this as best I can. CloudFlare handles ALL traffic. This is my ServerModule UniGUIServerModuleBeforeInit Setup:-
 

  BindToIpStr:= '192.168.1.25'; // This is the Standalone UniGUI Server Bound IP on a Standalone PC with the NIC Bound IP
  HttpPort:= 80;
  //
  Bindings.BeginUpdate;
  Bindings.Clear;
  // Add Blank Binding (making sure it is valid entry where later we set Port/IP)
  with Bindings.Add do begin
    IP:= '';  
    Port:= 0; 
  end;
  Bindings.EndUpdate;
  // Reference that added binding and set values
  if Bindings.Count > 0 then begin
    Bindings.Items[0].Port:= HttpPort;
    Bindings.Items[0].IP:=   BindToIpStr;
    Bindings.Items[0].BroadcastEnabled:= True;
  end else begin
    Port:= HttpPort; // Default http
  end;

CloudFlare communicates with the users browser in http and https mode irrespective of UniGUI mode.

UniGUI Server sees only port 80 traffic after CloudFlare has encrypted / unencrypted web traffic stream.

SO again I ask if we can enable the UniGUI Standalone Server WebSockets even if the ServerModule is not enabling SSL.

I do not know how to say this any other way.

 

 

  • Administrators
Posted

You can enable websockets regardless of the HTTP or HTTPS prorocols.

If the incoming traffic is HTTP then uniGUI will also listen to Websockets on non-secure ws:// protocol. 

If the incoming traffic is HTTPS then uniGUI will listen to Websockets on secure wss:// protocol. 

If you enable the option "AlwaysUseHTTP", then uniGUI will always listen on ws:// protocol regardless of the website protocol.

 

  • 2 weeks later...
Posted
On 1/20/2026 at 7:04 AM, Farshad Mohajeri said:

Hi, 

For this you don't need to use websockets. Simply make a http call to the server and handle it in one of the nodes. (the persistent node preferably ) then broadcast the message to unigui sessions. 

Hello, could someone share an example of this solution in code? If this requires some notes, it would be important to receive them. Thank you

  • Like 1

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...