Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting the client's IP in a Node.js websocket connection (socket.io)
    text
    copied!<p>The question is in the title.</p> <p>I've been roaming the web for what seems like an eternity to find out how to get the client's IP after a connection.</p> <p>No amount of ws.request, ws._socket, ws.adress() or ws.everyfreakingthingthereisoutthere gave me any result.The server's IP is 192.168.0.23 , the client's is 192.168.0.15 .</p> <p>The connection works well (I can send, receive, connect and close connections just fine). in it.</p> <p><em>The server's IP is 192.168.0.23 , the client's is 192.168.0.15 . edit: Also tried with in localhost and with another external machine on a different router (with external IP adress)</em></p> <pre><code>wss.on('connection', function(ws) { console.log(ws.what?); ws.on('message', function(message) { console.log('received : %s', message); }); ws.on('close', function(){ }); ws.send('HELLO'); }); </code></pre> <p>I'd be very thankful for any help I can get!</p> <p>EDIT : I effectively continued looking for a solution without any result. <strong>No documentation</strong> is available online, not sure why, but getting the IP adress of the client should be an easy enough thing to do.</p> <p>I'm really lost here, I've put many hours into this problem and can't seem to fix it. Everybody online seem to have different solutions working, and other not working, I'm not sure if it depends on the version, but on the latest version none of them seem to work.</p> <p>Again, I'd be very grateful for any tip that would allow me to take a step forward with this issue, I'm trying my best.</p> <p>EDIT : <a href="http://pastebin.com/C7jKPAwH" rel="nofollow">Here is a log corresponding on <strong>console.log(ws)</strong> on connection to help with the search.</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload