nodejs:尝试与SignalR api通讯时发生未知错误

时间:2019-06-12 13:09:12

标签: node.js signalr

我正试图使用​​此包装系统

https://www.npmjs.com/package/signalr-client

与用C#编写的SignalR api交谈,但是在尝试创建客户端时出现了一些错误

这是我的代码

var signalR = require('signalr-client');

try
{
    var client  = new signalR.client(
        "https://firouzex.exphoenixtrade.com/realtime",
        ['GetNewAPIToken' , 'OmsClientHub']
    );


}
catch (e) {
        console.log('error');
}

但是我得到这个错误

Error Message:  Protocol Error
Exception:  undefined
Error Data:  Url {
  protocol: 'https:',
  slashes: true,
  auth: null,
  host: 'firouzex.exphoenixtrade.com',
  port: null,
  hostname: 'firouzex.exphoenixtrade.com',
  hash: null,
  search:
   '?connectionData=%5B%7B%22name%22%3A%22getnewapitoken%22%7D%2C%7B%22name%22%3A%22omsclienthub%22%7D%5D&clientProtocol=1.5',
  query:
   [Object: null prototype] {
     connectionData: '[{"name":"getnewapitoken"},{"name":"omsclienthub"}]',
     clientProtocol: '1.5' },
  pathname: '/realtime/negotiate',
  path:
   '/realtime/negotiate?connectionData=%5B%7B%22name%22%3A%22getnewapitoken%22%7D%2C%7B%22name%22%3A%22omsclienthub%22%7D%5D&clientProtocol=1.5',
  href:
   'https://firouzex.exphoenixtrade.com/realtime/negotiate?connectionData=%5B%7B%22name%22%3A%22getnewapitoken%22%7D%2C%7B%22name%22%3A%22omsclienthub%22%7D%5D&clientProtocol=1.5',
  headers: {} }

1 个答案:

答案 0 :(得分:1)

已知问题“ client.Proxy设置当前仅适用于HTTP,不适用于HTTPS”。还有一个用于https https://www.npmjs.com/package/signalrjs的程序包。从npm package for signalr client not getting connected

复制了它