我正在尝试使用库sails.io 从我的cordova 客户端连接到基于sails 的服务器。这是我的客户代码:
<!-- 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>
当我打开浏览器时,我收到此错误:
Socket is trying to reconnect to Sails...
_-|>_- (attempt #1)
sails.io.js:136
Socket is trying to reconnect to Sails...
_-|>_- (attempt #2)
并且它一直在尝试重新连接(它不会停止)。我已经使用 socket.io 在我的服务器上建立了一个聊天,但那是本地的,所以我很确定它与 cors 有关。