safari, socket.io and websockerts #336

Closed
alnikitich opened this Issue Nov 17, 2012 · 1 comment

Comments

Projects
None yet
2 participants
@alnikitich

Hellow
I have trouble in Safari 5.1.7, socket.io and websockets

i use next example:
on node.js

var app = require('express')()
  , server = require('http').createServer(app)
  , io = require('socket.io').listen(server);


app.use("/1",require('express').static(__dirname + '/'));
server.listen(88);

app.get('/', function (req, res) {
  res.sendfile(__dirname + '/index.html');
});

io.sockets.on('connection', function (socket) {
  setInterval(function(){socket.emit('news', { hello: 'world' });},1000)
  socket.on('my other event', function (data) {
    console.log(data);
  });
});

on client

<script src="/socket.io/socket.io.js"></script>
<script>
  var socket = io.connect('http://localhost');
  socket.on('news', function (data) {
    console.log(data);
    socket.emit('my other event', { my: 'data' });
  });
</script>

and proxy on node.js

var http = require('http'),
    httpProxy = require('http-proxy');

//
// Create an instance of node-http-proxy
//
var proxy = new httpProxy.HttpProxy({
  target: {
    host: 'localhost',
    port: 88
  }
});

var server = http.createServer(function (req, res) {
  //
  // Proxy normal HTTP requests
  //
  proxy.proxyRequest(req, res);
});

server.on('upgrade', function(req, socket, head) {
  //
  // Proxy websocket requests too
  //
  proxy.proxyWebSocketRequest(req, socket, head);
});

server.listen(80);

if i navigate in safari http://localhost/1/1.html i have this log on nodejs server (by use proxy-server):

info: socket.io started
debug: client authorized
info: handshake authorized SSNP3bazdCmgZNlgBKFK
debug: client authorized
info: handshake authorized dzPUsJTm-KjTp2bZBKFL
debug: setting request GET /socket.io/1/websocket/dzPUsJTm-KjTp2bZBKFL
debug: set heartbeat interval for client dzPUsJTm-KjTp2bZBKFL
debug: client authorized for
debug: setting request GET /socket.io/1/xhr-polling/dzPUsJTm-KjTp2bZBKFL?t=1353166673061
debug: setting poll timeout
debug: discarding transport
debug: cleared heartbeat interval for client dzPUsJTm-KjTp2bZBKFL
debug: clearing poll timeout
debug: xhr-polling writing 5:::{"name":"news","args":[{"hello":"world"}]}
debug: set close timeout for client dzPUsJTm-KjTp2bZBKFL
debug: setting request GET /socket.io/1/xhr-polling/dzPUsJTm-KjTp2bZBKFL?t=1353166673998
debug: setting poll timeout
debug: discarding transport
debug: cleared close timeout for client dzPUsJTm-KjTp2bZBKFL
debug: clearing poll timeout
debug: xhr-polling writing 5:::{"name":"news","args":[{"hello":"world"}]}
debug: set close timeout for client dzPUsJTm-KjTp2bZBKFL
debug: setting request GET /socket.io/1/xhr-polling/dzPUsJTm-KjTp2bZBKFL?t=1353166675002

if i navigate it w\o proxy i have:

info: socket.io started
debug: served static content /socket.io.js
debug: client authorized
info: handshake authorized 9HxcJEKYo1yV6flwBixA
debug: setting request GET /socket.io/1/websocket/9HxcJEKYo1yV6flwBixA
debug: set heartbeat interval for client 9HxcJEKYo1yV6flwBixA
debug: client authorized for
debug: websocket writing 1::
debug: websocket writing 5:::{"name":"news","args":[{"hello":"world"}]}
debug: websocket received data packet 5:::{"name":"my other event","args":[{"my":"data"}]}
{ my: 'data' }
debug: websocket writing 5:::{"name":"news","args":[{"hello":"world"}]}
debug: websocket received data packet 5:::{"name":"my other event","args":[{"my":"data"}]}
{ my: 'data' }

but if at start i open page w/o proxy (http://localhost:88/1/1.html) and in the next time i open page with proxy (http://localhost/1/1.html) then i have good log (with websockets)

Trouble: i can`t use http-proxy with safari for socketio and WS

@jcrugzz

This comment has been minimized.

Show comment
Hide comment
@jcrugzz

jcrugzz Oct 30, 2015

Member

Closing due to old age.

Member

jcrugzz commented Oct 30, 2015

Closing due to old age.

@jcrugzz jcrugzz closed this Oct 30, 2015

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