From 5207cf76b920e30c2907d5b358b60059100a2850 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Parent Date: Wed, 10 Dec 2014 14:41:49 -0500 Subject: [PATCH] We have seen these errors: ERROR:tornado.general:Attempted to attach to session 7ceo057h (::1) from different IP (127.0.0.1) ERROR:tornado.general:Attempted to attach to session 60qsy81d (127.0.0.1) from different IP (::1) Normalize the ipv6 to ipv4 expression of localhost. --- sockjs/tornado/session.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sockjs/tornado/session.py b/sockjs/tornado/session.py index 95e2edf..57d3efe 100644 --- a/sockjs/tornado/session.py +++ b/sockjs/tornado/session.py @@ -267,7 +267,8 @@ def set_handler(self, handler, start_heartbeat=True): if self._verify_ip and self.conn_info is not None: # If IP address doesn't match - refuse connection - if handler.request.remote_ip != self.conn_info.ip: + localv6 = lambda ip: '127.0.0.1' if ip == '::1' else ip + if localv6(handler.request.remote_ip) != localv6(self.conn_info.ip): LOG.error('Attempted to attach to session %s (%s) from different IP (%s)' % ( self.session_id, self.conn_info.ip,