From af7db83bdc1212dcfdc14b38eee27fc3d2f570a9 Mon Sep 17 00:00:00 2001 From: gerdstolpmann Date: Sat, 4 Apr 2020 04:41:36 +0200 Subject: [PATCH] do not try to set remoteIP for websocket connections (#81) --- broker/client.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/broker/client.go b/broker/client.go index ff7ca8b..c3cc96d 100644 --- a/broker/client.go +++ b/broker/client.go @@ -94,7 +94,12 @@ var ( func (c *client) init() { c.status = Connected c.info.localIP, _, _ = net.SplitHostPort(c.conn.LocalAddr().String()) - c.info.remoteIP, _, _ = net.SplitHostPort(c.conn.RemoteAddr().String()) + remoteAddr := c.conn.RemoteAddr() + remoteNetwork := remoteAddr.Network() + c.info.remoteIP = "" + if remoteNetwork != "websocket" { + c.info.remoteIP, _, _ = net.SplitHostPort(remoteAddr.String()) + } c.ctx, c.cancelFunc = context.WithCancel(context.Background()) c.subMap = make(map[string]*subscription) c.topicsMgr = c.broker.topicsMgr