Linked Questions

Popular Questions

Excel JS add-in communicate with localhost via websockets

Asked by At

We are attempting to communicate from within an Excel 365 add-in (Javascript) to our application written in C++/Qt using websockets. The application is running on the local computer and operates as a secure websockets server with a self-signed certificate.

I can establish a websockets connection from Edge or Chrome to our local application, but cannot establish one from with the Excel add-in. Is there a security policy or similar which prevents Excel / Office JS add-ins from making a connection to localhost / 127.0.0.1?

It seems to be similar to the "Allow localhost loopback" setting in Edge, so I wondered if Office enforces that for additional security. If so, can it be disabled?

EDIT:

Here is the simple testing code:

if ("WebSocket" in window) {
        console.log("WebSocket is supported by your Browser!");

        // Let us open a web socket
        var ws = new WebSocket("wss://localhost:8080");

        ws.onopen = function () {

            // Web Socket is connected, send data using send()
            ws.send("Message to send");
            console.log("Message is sent...");
        };

        ws.onmessage = function (evt) {
            var received_msg = evt.data;
            console.log("Message is received...");
            console.log(received_msg);
        };

        ws.onclose = function () {

            // websocket is closed.
            console.log("Connection is closed...");
        };
    } else {

        // The browser doesn't support WebSocket
        console.log("WebSocket NOT supported by your Browser!");
    }

I do get the successful message in the log: "WebSocket is supported by your Browser!"

Related Questions