Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safari over windows client use xhr-polling instead of websocket - performance are severely harm #1147

Closed
yanivge opened this issue Jan 29, 2013 · 2 comments

Comments

@yanivge
Copy link

yanivge commented Jan 29, 2013

i used a simple client server socket.io communication over various environments using secured connection.
See in the table below, Safari behave differently on http and https
this cause a sever performance issue

server.js:
var fs = require('fs')
, privateKey = fs.readFileSync('/etc/httpd/certs/server.key').toString()
, certificate = fs.readFileSync('/etc/httpd/certs/server.crt').toString()
, options = {key: privateKey, cert: certificate}
//    ,app = require('https').createServer(options, handler)
, app = require('http').createServer(handler)   
, io = require('socket.io').listen(app);

app.listen(9000);

function handler(req, res) {
    fs.readFile(__dirname + '/client.html',
    function (err, data) {
        if (err) {
            res.writeHead(500);
            return res.end('Error loading client.html');
        }

    res.writeHead(200);
    res.end(data);
    });
}

io.configure(function () {
    io.set('log level', 3);
    io.set('transports', [
        'websocket',
        'flashsocket',
        'xhr-polling'/
    ]);
});

io.sockets.on('connection', function (socket) {
    socket.emit('news', { hello: 'Connected', timestamp: new Date() });
    socket.on('my other event', function (data) {
        console.log(data);

        setTimeout(function () {
            socket.emit('news', { hello: 'world', timestamp: new Date() });
        }, 1000);
    });
});
client.html:
<html>
    <head>
        <div>Simple example how Safari on windows use different transportation for http and https connections</div>
        <script src="/socket.io/socket.io.js"></script>
        <script>
            var baseUrl = window.location.protocol + "//" + window.location.host,
//          socket = io.connect(baseUrl,{secure:true});
            socket = io.connect(baseUrl);
            socket.on('news', function (data) {
                alert("got smth");
            setTimeout(function () {
                socket.emit('my other event', { my: 'data', timestamp: new Date() });
            }, 1000);
        });
        </script>
    </head>
    <body></body>
</html>
Results table:
Browser         (http)      (http)         (http)          (SSL)         (SSL)            (SSL) 
                Windows     Linux           Mac             Windows      Linux             Mac
FF(18)          websocket   websocket                       websocket    websocket  
IE(8)           flashsocket                                 flashsocket     
Chrom(24)       websocket   websocket                       websocket    websocket  
Safari          websocket                websocket         xhr-polling                  websocket
Opera(11)       flashsocket                                 flashsocket     
@citosid
Copy link

citosid commented Mar 6, 2014

Did you found any solution?

@yanivge
Copy link
Author

yanivge commented Mar 7, 2014

No.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants