janpantel / angular-sails

An angular module for using the sails socket.io api
MIT License
307 stars 56 forks source link

No catch of the error if the server is down #86

Open ilanfreoua opened 9 years ago

ilanfreoua commented 9 years ago

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 commented 9 years ago

anyone ?

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

TheSharpieOne commented 9 years ago

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.

ilanfreoua commented 9 years ago

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)