I am trying to connect to my sails based server from my cordova client using the library sails.io. this is my client code:
<!-- cordova script (this will be a 404 during development) -->
<script src="lib/ngCordova/dist/ng-cordova.js"></script>
<script src="cordova.js"></script>
<script src="lib/angular-socket-io/socket.js"></script>
<script src="lib/angular-sails/src/ngSails.js"></script>
<script src="lib\socket.io-client\socket.io.js"></script>
<script src="lib/sails.io.js/sails.io.js"></script>
<script type="text/javascript">
io.sails.useCORSRouteToGetCookie = false;
io.sails.url = 'http://178.62.83.248:1337/';
</script>
when i open the browser i get this error:
Socket is trying to reconnect to Sails...
_-|>_- (attempt #1)
sails.io.js:136
Socket is trying to reconnect to Sails...
_-|>_- (attempt #2)
and it keep trying to reconnect(it doesn't stop). i have already build a chat on my server using socket.io but that was locally so i'm pretty sure its has something to do with cors.
Your problem is likely a mismatch between your version of Sails and your version of sails.io.js. When you generate a Sails v0.10.5 app with
sails generate new
, it gives you the appropriate version of sails.io.js. But if you justnpm install sails.io.js
, you'll get the bleeding-edge version which is designed to work with the imminent v0.11 release of Sails, using Socket.io 1.0.Easiest thing to do here would be just download the file that Sails would use, which you can get here.
Same issue here, i ve got a sailsjs server thats running fine, just wanted to connect a node.js app to it. I tried the following code found here as linked per sails.js website and I get the same responses.
I think it might be from socket.io-client version as a npm list suggest that sails uses 0.9.17 version of socket.io and I use 1.3.2.