1
votes

I have a 3rd party server that runs SignalR. In order to connect to that server and read messages i have created a javascript code that should run from NodeJS on ec2 (Linux) instance. The issue is that when i try running my code that only connects to the server i'm getting this error: .....node_modules/signalr/jquery.signalR.js:1085 }(window.jQuery, window)); ^

ReferenceError: window is not defined

What kind of window? I have an ssh-only linux server? My existing JS code is this:

const signalR = require("signalr"); //here i can't use @aspnet/signalr or @microsoft/signalr because those aren't compatible with SignalR that's on the 3rd party server. UGH Microsoft!

let connection = new signalR.HubConnectionBuilder().withUrl("https://myurl/signalr/hubName")
    .configureLogging("warn")
        .build();

    connection.start().then(() => {
        console.log("yeeey!");
    }).catch((e) => {
        console.log(e);
    });

What are my options here in order to run this? I have installed NodeJS on ec2 instance using official Amazon tutorial so it should be the latest current version - 13.2

2

2 Answers

1
votes

Found a solution.... This library solved my problems

0
votes

Please write this:

import * as signalR from '@aspnet/signalr';