Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
JavaScript
var linkConditioningHubstart = $.connection.hub;
        hubstart.client.onMessageReceived = function (mac, jObj) {
            var sinrobj = JSON.stringify(jObj);
            var slApp = document.getElementById("slApp");
            slApp.Content.SL2JS.OnMessageReceived(mac, sinrobj);
            console.log(mac + ' ' + sinrobj);
        };

JavaScript
function StartStream(mac, ip, port) {
            {
            $.connection.hub.start()
            .done(function () {
            alert(result);
            console.log('Success');
            hubstart.server.startstreaming(mac, ip, port);
        })
        .fail(function () {
          
            console.log('Failure');
        });
           
        }


Some time the connection is lost or disconnect.. how to re connect the hub.. Pls help me i am new of SignalR
Posted
Comments
Andy Lanng 20-May-15 10:01am    
How is it disconnected?
You may find that your code-behind says that it is disconnected but it will retry automatically until it hooks up. Just suppress the errors if that's the case
Rnshanmugavadivel 20-May-15 10:13am    
In my code, SignalR connection stops automatically after some time when running from Visual Studio
Andy Lanng 20-May-15 10:52am    
It can time out. Is that what's happening? The only way that would happen is either it loses connection to the server or the code has stopped running (crashed or debugging)

PS: Use the 'reply' button or I won't get notifications of your response.
Rnshanmugavadivel 21-May-15 0:33am    
After some time i got below message

[09:42:03 GMT-0500 (Central Daylight Time)] SignalR: Attempting to connect to 'http://10.53.X.XXX/Dataview/signalr/poll?transport=
longPolling&connectionToken=i7N-VuzqjG53vwN3Z3JEY31NQhiUKpQzTogpbf2D32bZtZYAUaeKwIoGAifZTkyhmQen8-Vy5rGz3g5Mpl
-xjomcEt2UTKYmwFSZrxGe9JV0FVmNbWaCpU0fPxjB-lrV1uabalb0M4SjGCVciSvCIpFcqO71-p3XHnBmzQnsky1q41KV6PqBD0XrnmA1u6o_
0&connectionData=%5B%7B%22name%22%3A%22linkconditioninghub%22%7D%5D&groupsToken=0s3KLGRjhEQCrnWYCfMFMlN8FUQq_ZIDhcNHOWT1pD5a_
qDIY-W3UMEHpSxrAE-YPGZ_mwSeM_uQRANcg4OrCjUn7ftekqzTEsd-P3kFrn1pnou_cMmCURhCLJYCesgFvUe1J_UmKCe6YHN_
cvHU2OV9XIEpyRio3AGR5Z1gWsONDuWFck9StQ341JqtW0sAxQdg1BKDRM7u8LAX7E8qCYWUesvJAp4bPRQUfBAwUgY1&messageId=G%2C0%7CH%2C0%7CI%2C1%7CJ%2C0%7CK%2C3C&tid=5'
using longPolling.

Before each call check wheather it is disconnected then start it again as follows
and continue


$.connection.hub.disconnected(function () {
$.connection.hub.start();
});
 
Share this answer
 
Comments
Rnshanmugavadivel 21-May-15 1:51am    
SignalR connection stops automatically after some time when running from Visual Studio.

After some time i got below message

[09:42:03 GMT-0500 (Central Daylight Time)] SignalR: Attempting to connect to 'http://10.53.X.XXX/Dataview/signalr/poll?transport=
longPolling&connectionToken=i7N-VuzqjG53vwN3Z3JEY31NQhiUKpQzTogpbf2D32bZtZYAUaeKwIoGAifZTkyhmQen8-Vy5rGz3g5Mpl
-xjomcEt2UTKYmwFSZrxGe9JV0FVmNbWaCpU0fPxjB-lrV1uabalb0M4SjGCVciSvCIpFcqO71-p3XHnBmzQnsky1q41KV6PqBD0XrnmA1u6o_
0&connectionData=%5B%7B%22name%22%3A%22linkconditioninghub%22%7D%5D&groupsToken=0s3KLGRjhEQCrnWYCfMFMlN8FUQq_ZIDhcNHOWT1pD5a_
qDIY-W3UMEHpSxrAE-YPGZ_mwSeM_uQRANcg4OrCjUn7ftekqzTEsd-P3kFrn1pnou_cMmCURhCLJYCesgFvUe1J_UmKCe6YHN_
cvHU2OV9XIEpyRio3AGR5Z1gWsONDuWFck9StQ341JqtW0sAxQdg1BKDRM7u8LAX7E8qCYWUesvJAp4bPRQUfBAwUgY1&messageId=G%2C0%7CH%2C0%7CI%2C1%7CJ%2C0%7CK%2C3C&tid=5'
using longPolling.
Rnshanmugavadivel 21-May-15 6:00am    
how to check it's connected or disconnected?.Where to put above ur code in my code.Please help i am new of signalr and also fresher.
OK
just replace your following line

$.connection.hub.start()


with

following

$.connection.hub.disconnected(function () {
$.connection.hub.start();
});

Hope this is clear.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900