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

Browser Client Minification breaks Payload encoding/decoding #422

Closed
abdulmueid opened this issue Jul 26, 2011 · 3 comments
Closed

Browser Client Minification breaks Payload encoding/decoding #422

abdulmueid opened this issue Jul 26, 2011 · 3 comments
Labels
bug Something isn't working

Comments

@abdulmueid
Copy link

The minified browser client breaks the encoding/decoding of Payloads in the browser when using XHR-Polling.

Here is the code to reproduce the bug:

var io = io.listen(8080);
io.enable('browser client minification');  // send minified client
io.set('transports', ['xhr-polling']);
io.sockets.on('connection', function(client){
    client.on('message',function(msg){
        //Send messages in succession to create a payload
        client.send("Hello");
        client.send("Hello!");
        client.send("Hello!!");
        client.send("Hello!!!");
        client.send("Hello!!!!");
        console.log(msg);
    });
});

Code on the client side:

<html>
<head>
<script src="http://localhost:11027/socket.io/socket.io.js"></script>
<script>
    var socket = io.connect('http://localhost:11027');
    socket.on('message', function (msg) {
        document.getElementById('out').innerHTML = "<div>"+msg+"</div>" + document.getElementById('out').innerHTML;
    });
    function sendPayload() {
        //Send messages in succession to create a payload
        socket.send("Hello");
        socket.send("Hello!");
        socket.send("Hello!!");
        socket.send("Hello!!!");
        socket.send("Hello!!!!");       
    }

</script>
</head>
<body>
<button onClick="sendPayload();">Send Payload</button>
<div id="out"></div>
</body>
</html>

Upon clicking "Send Payload" button on the web page, we expect 5 "hello" on the server console and 25 "hello" on the client output. Only one arrives on each side.

Removing the client minification string from server side fixes the problem.

Tested on socket.io version 0.7.7, installed using NPM.

@3rd-Eden
Copy link
Contributor

Thanks for providing us with steps to reproduce. I'll look in to it

~ Arnout Kazemier

On Jul 26, 2011, at 2:54 AM, [email protected] wrote:

The minified browser client breaks the encoding/decoding of Payloads in the browser when using XHR-Polling.

Here is the code to reproduce the bug:

var io = io.listen(8080);
io.enable('browser client minification');  // send minified client
io.set('transports', ['xhr-polling']);
var looking = [];
io.sockets.on('connection', function(client){
   client.on('message',function(msg){
       //Send messages in succession to create a payload
       client.send("Hello");
       client.send("Hello!");
       client.send("Hello!!");
       client.send("Hello!!!");
       client.send("Hello!!!!");
       console.log(msg);
   });
});

Code on the client side:

<html>
<head>
<script src="http://localhost:11027/socket.io/socket.io.js"></script>
<script>
   var socket = io.connect('http://localhost:11027');
   socket.on('message', function (msg) {
       document.getElementById('out').innerHTML = "<div>"+msg+"</div>" + document.getElementById('out').innerHTML;
   });
   function sendPayload() {
       //Send messages in succession to create a payload
       socket.send("Hello");
       socket.send("Hello!");
       socket.send("Hello!!");
       socket.send("Hello!!!");
       socket.send("Hello!!!!");        
   }

</script>
</head>
<body>
<button onClick="sendPayload();">Send Payload</button>
<div id="out"></div>
</body>
</html>

Upon clicking "Send Payload" button on the web page, we expect 5 "hello" on the server console and 25 "hello" on the client output. Only one arrives on each side.

Removing the client minification string from server side fixes the problem.

Tested on socket.io version 0.7.7, installed using NPM.

Reply to this email directly or view it on GitHub:
#422

@3rd-Eden
Copy link
Contributor

Fixed with socketio/socket.io-client#254

@3rd-Eden
Copy link
Contributor

3rd-Eden commented Aug 3, 2011

Fix landed in master of socket.io-client, will be available in the next release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants