Skip to content

Commit 1117aad

Browse files
invisibleroadsfrancoijs
authored andcommitted
Replace localhost with explicit 127.0.0.1
1 parent d149d84 commit 1117aad

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

README.rst

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Emit. ::
4747

4848
from socketIO_client_nexus import SocketIO, LoggingNamespace
4949

50-
with SocketIO('localhost', 8000, LoggingNamespace) as socketIO:
50+
with SocketIO('127.0.0.1', 8000, LoggingNamespace) as socketIO:
5151
socketIO.emit('aaa')
5252
socketIO.wait(seconds=1)
5353

@@ -58,7 +58,7 @@ Emit with callback. ::
5858
def on_bbb_response(*args):
5959
print('on_bbb_response', args)
6060

61-
with SocketIO('localhost', 8000, LoggingNamespace) as socketIO:
61+
with SocketIO('127.0.0.1', 8000, LoggingNamespace) as socketIO:
6262
socketIO.emit('bbb', {'xxx': 'yyy'}, on_bbb_response)
6363
socketIO.wait_for_callbacks(seconds=1)
6464

@@ -78,7 +78,7 @@ Define events. ::
7878
def on_aaa_response(*args):
7979
print('on_aaa_response', args)
8080

81-
socketIO = SocketIO('localhost', 8000, LoggingNamespace)
81+
socketIO = SocketIO('127.0.0.1', 8000, LoggingNamespace)
8282
socketIO.on('connect', on_connect)
8383
socketIO.on('disconnect', on_disconnect)
8484
socketIO.on('reconnect', on_reconnect)
@@ -110,7 +110,7 @@ Define events in a namespace. ::
110110
print('on_aaa_response', args)
111111
self.emit('bbb')
112112

113-
socketIO = SocketIO('localhost', 8000, Namespace)
113+
socketIO = SocketIO('127.0.0.1', 8000, Namespace)
114114
socketIO.emit('aaa')
115115
socketIO.wait(seconds=1)
116116

@@ -129,7 +129,7 @@ Define standard events. ::
129129
def on_disconnect(self):
130130
print('[Disconnected]')
131131

132-
socketIO = SocketIO('localhost', 8000, Namespace)
132+
socketIO = SocketIO('127.0.0.1', 8000, Namespace)
133133
socketIO.wait(seconds=1)
134134

135135
Define different namespaces on a single socket. ::
@@ -146,7 +146,7 @@ Define different namespaces on a single socket. ::
146146
def on_aaa_response(self, *args):
147147
print('on_aaa_response', args)
148148

149-
socketIO = SocketIO('localhost', 8000)
149+
socketIO = SocketIO('127.0.0.1', 8000)
150150
chat_namespace = socketIO.define(ChatNamespace, '/chat')
151151
news_namespace = socketIO.define(NewsNamespace, '/news')
152152

@@ -159,11 +159,11 @@ Connect via SSL (https://github.com/invisibleroads/socketIO-client/issues/54). :
159159
from socketIO_client_nexus import SocketIO
160160

161161
# Skip server certificate verification
162-
SocketIO('https://localhost', verify=False)
162+
SocketIO('https://127.0.0.1', verify=False)
163163
# Verify the server certificate
164-
SocketIO('https://localhost', verify='server.crt')
164+
SocketIO('https://127.0.0.1', verify='server.crt')
165165
# Verify the server certificate and encrypt using client certificate
166-
socketIO = SocketIO('https://localhost', verify='server.crt', cert=(
166+
socketIO = SocketIO('https://127.0.0.1', verify='server.crt', cert=(
167167
'client.crt', 'client.key'))
168168

169169
Specify params, headers, cookies, proxies thanks to the `requests <http://python-requests.org>`_ library. ::
@@ -172,7 +172,7 @@ Specify params, headers, cookies, proxies thanks to the `requests <http://python
172172
from base64 import b64encode
173173

174174
SocketIO(
175-
'localhost', 8000,
175+
'127.0.0.1', 8000,
176176
params={'q': 'qqq'},
177177
headers={'Authorization': 'Basic ' + b64encode('username:password')},
178178
cookies={'a': 'aaa'},
@@ -182,7 +182,7 @@ Wait forever. ::
182182

183183
from socketIO_client_nexus import SocketIO
184184

185-
socketIO = SocketIO('localhost', 8000)
185+
socketIO = SocketIO('127.0.0.1', 8000)
186186
socketIO.wait()
187187

188188
Don't wait forever. ::
@@ -191,7 +191,7 @@ Don't wait forever. ::
191191
from socketIO_client_nexus import SocketIO
192192

193193
try:
194-
socket = SocketIO('localhost', 8000, wait_for_connection=False)
194+
socket = SocketIO('127.0.0.1', 8000, wait_for_connection=False)
195195
socket.wait()
196196
except ConnectionError:
197197
print('The server is down. Try again later.')

socketIO_client_nexus/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,15 +334,15 @@ class SocketIO(EngineIO):
334334
- Pass query params, headers, cookies, proxies as keyword arguments.
335335
336336
SocketIO(
337-
'localhost', 8000,
337+
'127.0.0.1', 8000,
338338
params={'q': 'qqq'},
339339
headers={'Authorization': 'Basic ' + b64encode('username:password')},
340340
cookies={'a': 'aaa'},
341341
proxies={'https': 'https://proxy.example.com:8080'})
342342
"""
343343

344344
def __init__(
345-
self, host='localhost', port=None, Namespace=SocketIONamespace,
345+
self, host='127.0.0.1', port=None, Namespace=SocketIONamespace,
346346
wait_for_connection=True, transports=TRANSPORTS,
347347
resource='socket.io', hurry_interval_in_seconds=1, **kw):
348348
self._namespace_by_path = {}

socketIO_client_nexus/namespaces.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def on_event(self, event, *args):
116116
117117
- Call socketIO.on()
118118
119-
socketIO = SocketIO('localhost', 8000)
119+
socketIO = SocketIO('127.0.0.1', 8000)
120120
socketIO.on('my_event', my_function)
121121
122122
- Call namespace.on()

socketIO_client_nexus/tests/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from ..exceptions import ConnectionError
88

99

10-
HOST = 'localhost'
10+
HOST = '127.0.0.1'
1111
PORT = 9000
1212
DATA = 'xxx'
1313
PAYLOAD = {'xxx': 'yyy'}

socketIO_client_nexus/tests/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script src="/socket.io/socket.io.js"></script>
22
<script>
3-
var socket = io('//localhost:8000');
3+
var socket = io('//127.0.0.1:8000');
44
var chat = io('/chat');
55
var news = io('/news');
66

socketIO_client_nexus/tests/proxy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
var proxy = require('http-proxy').createProxyServer({
2-
target: {host: 'localhost', port: 9000}
2+
target: {host: '127.0.0.1', port: 9000}
33
}).on('error', function(err, req, res) {
44
console.log('[ERROR] %s', err);
55
res.end();

0 commit comments

Comments
 (0)