Skip to content

Instantly share code, notes, and snippets.

@yosuke-furukawa
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yosuke-furukawa/35b37013c5dcfcb15e52 to your computer and use it in GitHub Desktop.
Save yosuke-furukawa/35b37013c5dcfcb15e52 to your computer and use it in GitHub Desktop.
ios safari indicator keeps spinnig...

Problem

ios safari indicator keeps spinning on cross domain.

However, when i use same origin, ios safari indicator does not spin.

I guess "polling" connection keeps and does not close the transport even if upgrade to websocket on cross domain.

I used Safari debug tool, and see the timeline, But I can't find the polling connection...

app.js

var static = require('node-static');
var file = new static.Server('.');
server = require('http').createServer(function (request, response) {
    request.addListener('end', function () {
      file.serve(request, response);
    }).resume();
});
// different origin, static file server port is 60000
server.listen(60000);
// but socket.io server port is 60001
var io = require('socket.io').listen(60001);
io.sockets.on('connection', function(socket){
  socket.on('message', function(){
    socket.emit("reply","hello");
  });
  socket.on('disconnect', function(){});
});

index.html

<!DOCTYPE html>
<html>
<head>
<title>sample</title>
</head>
<body>
  <div id="Continar">
  </div>
    <script src="http://localhost:60001/socket.io/socket.io.js"></script>
    <script>
      var socket = io.connect('http://localhost:60001');//, {transports: ["websocket", "polling"]});
      socket.on('connect', function() {
        socket.emit("message","hay");
      });
      socket.on('reply', function(msg) {
        document.getElementById("Continar").innerHTML = msg;
      });
    </script>
</body>
</html>

workaround

client transports order change, the indicator does not spin.

<!DOCTYPE html>
<html>
<head>
<title>sample</title>
</head>
<body>
  <div id="Continar">
  </div>
    <script src="http://localhost:60001/socket.io/socket.io.js"></script>
    <script>
      var socket = io.connect('http://localhost:60001', {transports: ["websocket", "polling"]});
      socket.on('connect', function() {
        socket.emit("message","hay");
      });
      socket.on('reply', function(msg) {
        document.getElementById("Continar").innerHTML = msg;
      });
    </script>
</body>
</html>

Full code is here

https://github.com/yosuke-furukawa/socketio-test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment