locked
Not able to send messages to all users in production (other users connectionids are not visible) RRS feed

  • Question

  • User-117074196 posted

    All my connections and messages are working perfectly on localhost as well as If I deploy app in IIS on windows 10.

    But when the app is deployed to windows server 2012. App is not able to maintain all the available connection Ids on real time because of which app is not able to perform chat.

    For understanding I have this method

    in my chathub.vb which sends all the available connectionsid on the server to the client side.

    Public Sub getGonnected()

    Clients.Client(Context.ConnectionId).hello("Connection is connected CONNECTIONID = " + Context.ConnectionId)

    Dim heartBeat = GlobalHost.DependencyResolver.Resolve(Of ITransportHeartbeat)()
    Dim connectionAlive = heartBeat.GetConnections().Where(Function(c) c.ConnectionId <> Context.ConnectionId).ToList()
    Clients.Client(Context.ConnectionId).hello("Other Connections Available ..")
    For Each item In connectionAlive
    Clients.Client(Context.ConnectionId).hello(item.ConnectionId)


    Next

    Clients.Client(Context.ConnectionId).hello("End of other connections available")
    End Sub

    on the client side the method is called after every 5 secs like this i document.ready function

    chat.client.hello = function (ping) {
    console.log(ping);
    }


    $.connection.hub.start().done(function () {

    });

    setInterval(function () {

    chat.server.getGonnected().done(function (result) {
    console.log('connectionRequestsent')
    });

    }, 5000);

    Also in my web.config I have added following settings

    <modules runAllManagedModulesForAllRequests="true">
    </modules>

    target framework 4.5

    As per above example code above

    I am not able to see a new connection in the borwsers console when some new user registers will signalr. And also that new user is unable to see the ConnectionId's of already present users in signalr in the browser console.

    This thing is only happening on server. An help would be much appretiated. I have already enabled websockets and my websockets handshake is successfull. Moreover the spefic conntectionId is able to send and recieve messages to and from server. But not with other connectionId as the are not availble.

    Any help or guidance will be muc appreciated.

    Regards

    Abdul

    Monday, April 16, 2018 9:05 AM

All replies

  • User61956409 posted

    Hi abduljanjua,

    Do you mean that the hub server does not push messages to each available connecting client in foreach loop?  You can try to write the log to trace if connectionAlive is empty. And you can enable SignalR Tracing to view diagnostic information.

    Besides, if you’d like to store and maintain connectionId of connecting users in list and then push message to each user based on connectionId, you can try to override OnConnected() event to add new connectionId to list, and then you can retrieve connectionId from that list and send message to user based on connectionId.

    With Regards,

    Fei Han

    Tuesday, April 17, 2018 2:28 AM
  • User-117074196 posted

    Hi Fei Han,

    Thank for your reply.

    yes I am already updating the users connection Id By overding OnConnected event and also maintining there connectionIds by overiding onreconnected event.

    I am creating a live chat support application usin signalr.

    So my code woks fine in local envoriment (event I left chat for an hour or two and after comming back I was able to send and recieve messages). Application also work fine on our staging windows server. 

    The problem is only one our production windows server 2012 (unfortunately I do not have access to the server to dig inside). To the server guy I have aks to install websockets which he has and websocket connection is successful now. Besides this are there any other settings we need to check?

    You can check the working demo of our staging environment using these links (working fine here)
    http://chatsupport.codicx.com/Online_Chat_Support/OnlineChatSupport.aspx# (supposed admin panel)
    http://chatplugin.codicx.com/(supposed client side)

    Open in separate browsers 

    but the same workaround does not work on our production server.

    Tuesday, April 17, 2018 8:46 AM
  • User61956409 posted

    Hi abduljanjua,

    According to the code you provided, it is push message to specific clients based on connectionId via 

    Clients.Client(Context.ConnectionId).hello("xxxx")

    I’d like to know if you call Clients.All.hello("xxxx") to push message to all connecting clients, does it work fine on your production server?

    With Regards,

    Fei Han

    Wednesday, April 18, 2018 8:10 AM