angular-sails icon indicating copy to clipboard operation
angular-sails copied to clipboard

No catch of the error if the server is down

Open ilanfreoua opened this issue 10 years ago • 3 comments

Hello,

I am using angular-sails to connect my Node Server to an ionic application through Socket.io. Its very functionnal and useful, Thanks ! ;)

But, if the server is down, i have this error :

WebSocket connection to 'ws://myapi.com:1337/socket.io/?__sails_io_sdk_version=0.11.0&__sails_io_sdk_platform=browser&__sails_io_sdk_language=javascript&EIO=3&transport=websocket' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED

I was not able to found any information if its possible to catch the error. Actually, if the server is down, this make crashing my app because of this error.. Is there a way to detect the error ? I mean, when I use Promises, I have the success callback which is triggered in case of 200 http response and error callbacks which are triggered in case of 404/502 errors, but the error callback is not triggered when the server is down.

Am I wrong on something ?

thank you

ilanfreoua avatar Oct 20 '15 08:10 ilanfreoua

anyone ?

I tried to use interceptors , but its not working as $http...

ilanfreoua avatar Oct 23 '15 15:10 ilanfreoua

If you are using the 2.0 branch this issue can be addressed, but since the 1.0 branch uses sails.io.js it makes it hard to get at the error to catch it.

TheSharpieOne avatar Oct 24 '15 03:10 TheSharpieOne

Hmm I can intercept the error when its like 403 or 401, for this, i am using this : $sailsProvider.interceptors.push('mySailsInterceptor');

but i would like to know if its possible to intercept if the connection is lost (no internet connection or the api server is down)

ilanfreoua avatar Oct 25 '15 09:10 ilanfreoua