Not getting remote address while using proxy in socket.io

后端 未结 3 1040
余生分开走
余生分开走 2020-12-28 09:18

In my socket.io code,

socket.sockets.on(\'connection\', function(client){ 
    var ip = client.handshake.address.address;
    ..
}

ip alwa

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-28 09:54

    In version > 1.0, the syntax is similar:

    socket.handshake.headers['x-forwarded-for'] || socket.request.connection.remoteAddress;
    

提交回复
热议问题