Search code examples
angular-cliangular5asp.net-core-signalr

Angular 5.1.1 infinite refresh loop after set proxy for signalr?


I'm working with Angular 5.1.1 and @angular/cli ^1.6.1.
I want to use Asp.Net Core SignalR.
So I have the following proxy setting:

const PROXY_CONFIG = [
  {
    context: [
      "/api",
      "/Temp",
      "/Upload",
      "/notificationHub",
      "/sockjs-node"
    ],
    target: "http://localhost:52918/",
    changeOrigin: true,
    secure: false,
    logLevel: 'debug',
    ws: true
  }
];

module.exports = PROXY_CONFIG;

I start project with ng serve --proxy-config proxy.config.js command
But upon http://localhost:4200/ comes up, I get the following message in command line and page refresh and this repeat until infinite

[HPM] POST /api/Category/GetAll/ -> http://localhost:52918/
[HPM] POST /api/Product/GetAllActives/ -> http://localhost:52918/
[HPM] OPTIONS /notificationHub -> http://localhost:52918/
[HPM] GET /notificationHub?id=dedf5495-4438-4a9a-9742-d4b16fe0c94b -> http://localhost:52918/
[HPM] Upgrading to WebSocket
[HPM] GET /sockjs-node/505/k1gctvfq/websocket -> http://localhost:52918/
[HPM] Upgrading to WebSocket
[HPM] GET /sockjs-node/156/bsye5nne/websocket -> http://localhost:52918/
[HPM] Upgrading to WebSocket
[HPM] Client disconnected
[HPM] POST /api/Category/GetAll/ -> http://localhost:52918/
[HPM] POST /api/Product/GetAllActives/ -> http://localhost:52918/
[HPM] OPTIONS /notificationHub -> http://localhost:52918/
[HPM] GET /notificationHub?id=afc731c5-98ba-450a-84b3-f023e7770b37 -> http://localhost:52918/
[HPM] Upgrading to WebSocket
[HPM] GET /sockjs-node/627/d0yup2yn/websocket -> http://localhost:52918/
[HPM] Upgrading to WebSocket
[HPM] GET /sockjs-node/069/y3cwf4bi/websocket -> http://localhost:52918/
[HPM] Upgrading to WebSocket
[HPM] Client disconnected

infinite refresh loop, angular cli

How can we stop infinite refresh loop?


Solution

  • Finally I could find the solution
    I have to change proxy config as follows:

    const PROXY_CONFIG = [
      {
        context: [
          "/api",
          "/Temp",
          "/Upload",
          "/notificationHub"
        ],
        target: "http://localhost:52918/",
        secure: false,
        logLevel: 'debug',
        ws: true
      }
    ];
    

    It's OK now