Skip to content

Commit f9467b2

Browse files
committed
Fix get client ip
1 parent 93117bd commit f9467b2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

JavaScript/2-WS/server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ const server = http.createServer(async (req, res) => {
6262

6363
const ws = new WebSocket.Server({ server });
6464

65-
ws.on('connection', (connection) => {
66-
console.log('Connected ' + connection.remoteAddress);
65+
ws.on('connection', (connection, req) => {
66+
console.log('Connected ' + req.socket.remoteAddress);
6767
connection.on('message', async (message) => {
6868
console.log('Received: ' + message);
6969
const obj = JSON.parse(message);

0 commit comments

Comments
 (0)