Skip to content

Commit 9b2888b

Browse files
committed
fix(apis/websocket): attempt to fix missing remote address
1 parent ba1a467 commit 9b2888b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

apis/websocket/src/index.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,13 @@ const wss = new WebSocketServer({
5656

5757
wss.on('connection', async (socket, request) => {
5858
try {
59-
if (!request.socket.remoteAddress) {
59+
const addrInfo = request.socket.address()
60+
if (!('address' in addrInfo)) {
6061
socket.close()
61-
return logger.warn('Connection failed because client is missing remote address')
62+
return logger.warn('Connection failed because client is missing remote address. addrInfo =', addrInfo)
6263
}
6364

64-
const id = `${request.socket.remoteAddress}:${request.socket.remotePort}`
65+
const id = `${addrInfo.address}:${addrInfo.port}`
6566

6667
if (clientIds.has(id)) {
6768
logger.warn(`Client ${id} already connected, disconnecting old session`)

0 commit comments

Comments
 (0)