When using socket.IO in a Node.js server, is there an easy way to get the IP address of an incoming connection? I know you can get it from a standard HTTP connection, but socket.io is a bit of a different beast.
相关问题
- npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fs
- IPAddress.[Try]Parse parses 192.168 to 192.0.0.168
- google-drive can't get push notifications
- How to reimport module with ES6 import
- Why is `node.js` dying when called from inside pyt
相关文章
- node连接远程oracle报错
- How can make folder with Firebase Cloud Functions
- @angular-cli install fails with deprecated request
- node.js modify file data stream?
- How to resolve hostname to an ip address in node j
- Transactionally writing files in Node.js
- Log to node console or debug during webpack build
- Get file created date in node
Latest version works with:
on
socket.io
1.3.4 you have the following possibilities.socket.handshake.address
,socket.conn.remoteAddress
orsocket.request.client._peername.address
use
socket.request.connection.remoteAddress
In socket.io 2.0: you can use:
socket.conn.transport.socket._socket.remoteAddress
works with
transports: ['websocket']
Version 0.7.7 of Socket.IO now claims to return the client's IP address. I've had success with: