SignalR is working fine in one app and unable to work in another app

Hi Everyone,

I am facing a strange issue. I have 2 ionic apps. I have implemented SignalR in both application.

Now the issue is it is working fine in one app. In another app, it can connect to server and create Connection Id, but unable to receive message.

Can anyone help me to find out the reason why it is not working in another app?

Here is my ionic code and it is same for both apps.

import { Injectable } from '@angular/core';

const win = window as any ; 
const $ = win.$ ;

@Injectable()
export class BackgroundServiceProvider {

  constructor() {
    console.log('Hello BackgroundServiceProvider');
  }

  startSignalR(){
    $(function () {

      //Set the hubs URL for the connection
      $.connection.hub.url = "http://localhost/api/signalr";

      var connectionId;
      $.connection.hub.start({ jsonp: true })
      .done(function(){ 
        connectionId = $.connection.hub.id;
        console.log('Now connected, connection ID=' + $.connection.hub.id); 
      }).fail(function(e){
        console.log(e);
      });

      $.connection.myHub.client.onMessageRecieved = function (userName, userType, message, notificationType) {
        console.log(userName + " " + userType + " " + message + " " + notificationType);
      }
    });
  }
 }

Here is my C# code.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.AspNet.SignalR;
using System.Threading.Tasks;
using Application.Models;

namespace Application
{
    public class MyHub : Hub
    {
        public static class UserHandler
        {
            public static HashSet<string> ConnectedId = new HashSet<string>();
        }

        public override Task OnConnected()
        {
            UserHandler.ConnectedId.Add(Context.ConnectionId);
            return base.OnConnected();
        }

        public override Task OnDisconnected(bool flag)
        {
            return base.OnDisconnected(flag);
        }

        public void sendNotification(string userName, string userType, string message, string notificationType)
        {
            Clients.All.onMessageRecieved(userName, userType, message, notificationType);
        }
        
        public void GetConnectionId()
        {
            Clients.Client(Context.ConnectionId).getUser(UserHandler.ConnectedId);
        }
    }
}

Thanks

Hi @Jerry29, I know this is a really old post, but by any chance do you remember how did you solve this issue? I am facing the same issue but couldn’t find a proper solution on net.
I am using signalr serverless service and I don’t have any startup.cs page where I can set my CORS. I am calling azure functions, which has signalr output bindings.
My Ionic web app receives all messages, but in mobile app, I am only able to see the connection established properly. Messages are not coming on the mobile app.
Would really appreciate if you can help in this. Thanks!