invisibleroads / socketIO-client

A socket.io client library for Python
http://pypi.python.org/pypi/socketIO-client
MIT License
447 stars 205 forks source link

error on create connection #132

Open sawt00th opened 7 years ago

sawt00th commented 7 years ago

I use legacy support library for socket.io 0.9 (0.5.6) and i get error on created connections (string ): code from socketIO_client import SocketIO, BaseNamespace import logging logging.getLogger('socketIO-client').setLevel(logging.DEBUG) def test(*arg): print("first", *arg) with SocketIO('192.168.101.103', 9000, BaseNamespace, transports=["websocket"]) as socketec: socketec.on('hi', test)

error: Exception ignored in: <bound method SocketIO.__del__ of <socketIO_client.SocketIO object at 0x0064FE30>> Traceback (most recent call last): File "C:\Python34\lib\site-packages\socketIO_client\__init__.py", line 218, in __del__ File "C:\Python34\lib\site-packages\socketIO_client\__init__.py", line 294, in disconnect File "C:\Python34\lib\site-packages\socketIO_client\__init__.py", line 320, in _transport File "C:\Python34\lib\site-packages\socketIO_client\__init__.py", line 348, in _get_socketIO_session File "C:\Python34\lib\site-packages\socketIO_client\__init__.py", line 516, in _get_socketIO_session File "C:\Python34\lib\site-packages\socketIO_client\transports.py", line 318, in _get_response File "C:\Python34\lib\site-packages\requests\api.py", line 71, in get File "C:\Python34\lib\site-packages\requests\api.py", line 57, in request File "C:\Python34\lib\site-packages\requests\sessions.py", line 461, in request File "C:\Python34\lib\site-packages\requests\sessions.py", line 381, in prepare_request File "C:\Python34\lib\site-packages\requests\utils.py", line 100, in get_netrc_auth File "<frozen importlib._bootstrap>", line 2237, in _find_and_load File "<frozen importlib._bootstrap>", line 2222, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 2155, in _find_spec TypeError: 'NoneType' object is not iterable

I try 0,7 version and its work is well, but i need previuos socket.io protocol

invisibleroads commented 7 years ago

Possibly, would it work under Linux?

We haven't tested the library on Windows yet.

gavincyi commented 7 years ago

I experience the same issue in Ubuntu as well. Is it resolved? My version is 0.5.7.2. Failed both in python 2 and 3.

My same piece of code works in Windows but not in Ubuntu.

Traceback (most recent call last): File "/usr/local/lib/python3.4/dist-packages/socketIO_client/transports.py", line 175, in recv yield self._connection.recv() File "/usr/local/lib/python3.4/dist-packages/websocket/_core.py", line 293, in recv opcode, data = self.recv_data() File "/usr/local/lib/python3.4/dist-packages/websocket/_core.py", line 310, in recv_data opcode, frame = self.recv_data_frame(control_frame) File "/usr/local/lib/python3.4/dist-packages/websocket/_core.py", line 323, in recv_data_frame frame = self.recv_frame() File "/usr/local/lib/python3.4/dist-packages/websocket/_core.py", line 357, in recv_frame return self.frame_buffer.recv_frame() File "/usr/local/lib/python3.4/dist-packages/websocket/_abnf.py", line 336, in recv_frame self.recv_header() File "/usr/local/lib/python3.4/dist-packages/websocket/_abnf.py", line 286, in recv_header header = self.recv_strict(2) File "/usr/local/lib/python3.4/dist-packages/websocket/_abnf.py", line 371, in recvstrict bytes = self.recv(min(16384, shortage)) File "/usr/local/lib/python3.4/dist-packages/websocket/_core.py", line 427, in _recv return recv(self.sock, bufsize) File "/usr/local/lib/python3.4/dist-packages/websocket/_socket.py", line 93, in recv "Connection is already closed.") websocket._exceptions.WebSocketConnectionClosedException: Connection is already closed.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner self.run() File "/usr/lib/python3.4/threading.py", line 868, in run self._target(*self._args, **self._kwargs) File "/home/ubuntu/workspace/python/ws_api_socket2.py", line 54, in self.wst = threading.Thread(target=lambda: self.run(url)) File "/home/ubuntu/workspace/python/ws_api_socket2.py", line 75, in run self.ws.wait(1) File "/usr/local/lib/python3.4/dist-packages/socketIO_client/init.py", line 254, in wait self._process_events(timeout) File "/usr/local/lib/python3.4/dist-packages/socketIO_client/init.py", line 271, in _process_events for packet in self._transport.recv_packet(timeout): File "/usr/local/lib/python3.4/dist-packages/socketIO_client/transports.py", line 99, in recv_packet for packet_text in self.recv(timeout=timeout): File "/usr/local/lib/python3.4/dist-packages/socketIO_client/transports.py", line 178, in recv except websocket.SSLError as e: AttributeError: 'module' object has no attribute 'SSLError'

Exception ignored in: <bound method SocketIO.del of <socketIO_client.SocketIO object at 0x7f9914d8ff60>> Traceback (most recent call last): File "/usr/local/lib/python3.4/dist-packages/socketIO_client/init.py", line 218, in del File "/usr/local/lib/python3.4/dist-packages/socketIO_client/init.py", line 296, in disconnect File "/usr/local/lib/python3.4/dist-packages/socketIO_client/init.py", line 322, in _transport File "/usr/local/lib/python3.4/dist-packages/socketIO_client/init.py", line 350, in _get_socketIO_session File "/usr/local/lib/python3.4/dist-packages/socketIO_client/init.py", line 518, in _get_socketIO_session File "/usr/local/lib/python3.4/dist-packages/socketIO_client/transports.py", line 319, in _get_response File "/usr/local/lib/python3.4/dist-packages/requests/api.py", line 70, in get File "/usr/local/lib/python3.4/dist-packages/requests/api.py", line 56, in request File "/usr/local/lib/python3.4/dist-packages/requests/sessions.py", line 474, in request File "/usr/local/lib/python3.4/dist-packages/requests/sessions.py", line 394, in prepare_request File "/usr/local/lib/python3.4/dist-packages/requests/utils.py", line 113, in get_netrc_auth File "", line 2237, in _find_and_load File "", line 2222, in _find_and_load_unlocked File "", line 2155, in _find_spec TypeError: 'NoneType' object is not iterable

sawt00th commented 7 years ago

I solved this problem by disabling the module requests and send handshake from urllib. Module urllib need load with importlib module as: import importlib url_request = importlib.import_module('urllib.request') @invisibleroads i cannot try its on Linux os, i upgrade my server side socketIO libraly.