I am working on project of Ionic with angular and AspNet with SignalR that have chat module.
I use SignalR for Chat.It's working smoothly but some time i am getting error as per below screen shot and because of that it's get stop working at all.
I have hosted my service on IIS and creating proxy and communicating with client and server. Here is sample
(function () {
angular
.module('app')
.factory('SignalRFactory', SignalRFactory);
SignalRFactory.$inject = ['$rootScope', 'Hub', 'ionicToast'];
function SignalRFactory($rootScope, Hub, ionicToast) {
var signalRLocal = this;
var serverURL = 'https://serivcerURL.com/signalr';
//Hub setup
var hub = new Hub('CommunicationHub', {
rootPath: serverURL,
listeners: {
'send': function (data) {
console.log("send " + data);
}
},
errorHandler: function (error) {
//Here i am getting that websocket closed error
console.error(error);
}
});
signalRLocal.Connect = function (user) {
console.log("SignalR Connecting as :" + user.UserName);
hub.invoke('connect', user);
};
return signalRLocal;
}
})();
But i don't want to use "long Polling" at all. So can someone help me to figure out this issue without use of 'long Polling'. Can someone tell me what configuration i have to do at client side or at IIS level.
your socket seems to be getting disconnected because of inactivity, some hosts do that send a dummy heart-bit message every 50 seconds to keep the connection alive
-----------------
Please remember to click "Mark as Answer" the responsES that resolved your issue.
WebSocket requires the server to be using Windows Server 2012 or Windows 8, and .NET Framework 4.5. If these requirements are not met, SignalR will attempt to use other transports to make its connections. Also you need to use latest browsers in order
to support websockets. Check https://docs.microsoft.com/en-us/aspnet/signalr/overview/getting-started/supported-platforms.
Please try to update SinglaR application web.config like below:
None
0 Points
3 Posts
SignalR: getting error: WebSocket closed
Jul 28, 2017 06:16 AM|sagarh|LINK
I am working on project of Ionic with angular and AspNet with SignalR that have chat module.
I use SignalR for Chat.It's working smoothly but some time i am getting error as per below screen shot and because of that it's get stop working at all.
I have hosted my service on IIS and creating proxy and communicating with client and server. Here is sample
I have hosted service on IIS. I search for the solution and find something like this https://stackoverflow.com/questions/31011288/signalr-2-2-0-websocket-error-connecting-to-hub
I also try with above link solution by using "long Polling" as per below
But i don't want to use "long Polling" at all. So can someone help me to figure out this issue without use of 'long Polling'. Can someone tell me what configuration i have to do at client side or at IIS level.
Participant
1380 Points
608 Posts
Re: SignalR: getting error: WebSocket closed
Jul 28, 2017 11:47 AM|JBetancourt|LINK
try reconnecting when disconnected:
Please remember to click "Mark as Answer" the responsES that resolved your issue.
None
0 Points
3 Posts
Re: SignalR: getting error: WebSocket closed
Jul 29, 2017 04:11 AM|sagarh|LINK
i already did this and it's working fine but still i am getting that error
Participant
1380 Points
608 Posts
Re: SignalR: getting error: WebSocket closed
Jul 29, 2017 04:46 AM|JBetancourt|LINK
your socket seems to be getting disconnected because of inactivity, some hosts do that send a dummy heart-bit message every 50 seconds to keep the connection alive
Please remember to click "Mark as Answer" the responsES that resolved your issue.
None
0 Points
3 Posts
Re: SignalR: getting error: WebSocket closed
Jul 31, 2017 09:26 AM|sagarh|LINK
Yes, that's correct. but how to handle this issue.
Participant
990 Points
475 Posts
Re: SignalR: getting error: WebSocket closed
Aug 09, 2017 09:23 AM|zxj|LINK
Hi sagarh,
WebSocket requires the server to be using Windows Server 2012 or Windows 8, and .NET Framework 4.5. If these requirements are not met, SignalR will attempt to use other transports to make its connections. Also you need to use latest browsers in order to support websockets. Check https://docs.microsoft.com/en-us/aspnet/signalr/overview/getting-started/supported-platforms.
Please try to update SinglaR application web.config like below:
For more information,please refer to the link about how to deploy signlar in windows server 2012 :
http://blogs.msdn.com/b/timlee/archive/2013/03/21/hosting-a-signalr-application-on-windows-2008r2-and-iis-7-5.aspx
Understanding and Handling Connection Lifetime Events in SignalR
https://docs.microsoft.com/en-us/aspnet/signalr/overview/guide-to-the-api/handling-connection-lifetime-events
Regards,
zxj
Participant
1380 Points
608 Posts
Re: SignalR: getting error: WebSocket closed
Aug 09, 2017 01:02 PM|JBetancourt|LINK
send a dummy message on an interval
Please remember to click "Mark as Answer" the responsES that resolved your issue.