question

Aelita-5879 avatar image
0 Votes"
Aelita-5879 asked markdon commented

WebSocket issue (Outlook add-in)

Hi! [I apologize in advance for being a newbie]
I'd like to develop an Outlook add-in, which passes the text of the message to a websocket server with the translation model and gets the translation. At first I got a problem with ws connection and I got the impression that Outlook doesn't allow to use an insecure protocol. With the wss connection I still experience the same problem: WebSocket connection to 'wss://86.50.168.81/translate' failed: (without the specification of the error). I guess there is some issue with the certificate, but I'm not sure how to fix it.

The code itself is very basic (this one is for testing):

 const websocket = new WebSocket("wss://86.50.168.81:443/translate");
 const data = {'text': 'Hello', 'source': 'eng', 'target': 'ukr', 'model': 'default'};
    
 websocket.onopen = function (event) {
                 websocket.send(JSON.stringify(data));
 };
 websocket.onmessage = function (event) {
                 resp = JSON.parse(event.data);
                 $("#result-word")[0].innerText = resp['result'];
 };
 websocket.onerror = function (event) {
                 app.showNotification(event.message);
 };
 websocket.onclose = function (event) {
                 app.showNotification(event.code);
 };

Would be very grateful for any advice.

office-addins-dev
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I had the impression that HTTPS and valid certificates are requirements, but I can't easily find you the document that says that.

My solution for HTTPS locally involves buying certificates for a domain you own and modifying hosts so that domain points to 127.0.0.1 on your machine.

There's also a tool from OfficeDev that looks pretty straight forward: https://www.npmjs.com/package/office-addin-dev-certs

0 Votes 0 ·

0 Answers