title: OSError: [WinError 10038] An operation was attempted on something that is not a socket using opcua.client.py connect to opc ua server
body: <p>Hello I try to connect OPCUA server using opcua client.</p>
  
  <p>I have used simatic opcua server.</p>
  
  <p>I write a code using python</p>
  
  <pre><code>from opcua import Client
  </code></pre>
  
  <p>import pandas as pd
  import threading</p>
  
  <p>__all_ = ['communication']</p>
  
  <p>df = pd.read_excel(r'C:\OPCUA\Working_VF1_5.xls', sheet_name='Tag List')</p>
  
  <p>class Communication:</p>
  
  <pre><code>def __init__(self):
      self.is_connected = False
      self.plc = ""
      self.mylock = threading.Lock()
  
  
  # Connection method
  def opc_client_connect(self):
      try:
          # #  Read connection string for url
          url = read_clienturl()
          self.client = Client("opc.tcp://WAP120153:55101")
  
  
          # self.client.find_servers(uris='opc.tcp://WAP120153:55101/')
          print(self.client)
          self.client.connect()
          is_connected = True
          root = self.client.get_root_node()
          print(root)
          objects = root.get_child('Objects')
          symbols = objects.get_child('1:SYM:')
          stnname,plcname = get_station_plc_name()
          stnametostring = '7:' + stnname
          plcnametostring = '7:' + plcname
          station_name = symbols.get_child(stnametostring)
          self.plc = station_name.get_child(plcnametostring)
  
  
  
      except Exception as e:
          is_connected = False
          print("My error is :",e.args)
          self.client.disconnect()
  
  
      finally:
          if is_connected:
              return True
  
  def __getstate__(self):
      state = self.__dict__.copy()
      # Remove the unpicklable entries.
      del state['mylock']
      return state
  
  # def __setstate__(self, state):
  #     # Restore instance attributes.
  #     self.__dict__.update(state)
  
  
  # Declear property of a module
  @property
  def PLC(self):
      return self.plc
  </code></pre>
  
  <h1>Read connection settings from excel</h1>
  
  <p>def read_clienturl():</p>
  
  <pre><code>    data = df.iloc[2, 11]
      print(data)
      return data
  </code></pre>
  
  <p>def get_station_plc_name():</p>
  
  <pre><code>station_name = df.iloc[0, 11]
  plc_name = df.iloc[1, 11]
  return station_name,plc_name
  </code></pre>
  
  <h1>Main function call</h1>
  
  <p>if <strong>name</strong> == "<strong>main</strong>":
      comm = Communication()</p>
  
  <pre><code>print(f'plc name is : {comm.PLC}')
  while True:
      comm.opc_client_connect()
      browser_id = '7:' + 'AR SOV OPN LS'
      var = comm.PLC.get_child("7:AR SOV OPN LS")
      value = var.get_value()
      print("value is : ", value)
      comm.client.disconnect()
  </code></pre>
  
  <p>when I try to use this code I got an error:-</p>
  
  <p>File "C:\Users\chma02\AppData\Roaming\Python\Python37\site-packages\opcua\client\ua_client.py", line 96, in _run
      self._receive()
    File "C:\Users\chma02\AppData\Roaming\Python\Python37\site-packages\opcua\client\ua_client.py", line 114, in _receive
      self._call_callback(0, ua.UaStatusCodeError(msg.Error.value))
    File "C:\Users\chma02\AppData\Roaming\Python\Python37\site-packages\opcua\client\ua_client.py", line 124, in _call_callback
      .format(request_id, self._callbackmap.keys())
  opcua.ua.uaerrors._base.UaError: No future object found for request: 0, callbacks in list are dict_keys([2])
  My error is : ()
  Traceback (most recent call last):
    File "C:/my files/python files/SMSPLCSIMULATIONV2-master (1)/SMSPLCSIMULATIONV2-master/clientcomm_v1.py", line 28, in opc_client_connect
      self.client.connect()
    File "C:\Users\chma02\AppData\Roaming\Python\Python37\site-packages\opcua\client\client.py", line 259, in connect
      self.create_session()
    File "C:\Users\chma02\AppData\Roaming\Python\Python37\site-packages\opcua\client\client.py", line 360, in create_session
      response = self.uaclient.create_session(params)
    File "C:\Users\chma02\AppData\Roaming\Python\Python37\site-packages\opcua\client\ua_client.py", line 267, in create_session
      data = self._uasocket.send_request(request)
    File "C:\Users\chma02\AppData\Roaming\Python\Python37\site-packages\opcua\client\ua_client.py", line 78, in send_request
      data = future.result(self.timeout)
    File "C:\Users\chma02\AppData\Local\Programs\Python\Python37\lib\concurrent\futures_base.py", line 434, in result
      raise TimeoutError()
  concurrent.futures._base.TimeoutError</p>
  
  <p>During handling of the above exception, another exception occurred:</p>
  
  <p>Traceback (most recent call last):
    File "C:\Users\chma02\AppData\Roaming\Python\Python37\site-packages\opcua\client\client.py", line 271, in disconnect
      self.close_session()
    File "C:\Users\chma02\AppData\Roaming\Python\Python37\site-packages\opcua\client\client.py", line 476, in close_session
      return self.uaclient.close_session(True)
    File "C:\Users\chma02\AppData\Roaming\Python\Python37\site-packages\opcua\client\ua_client.py", line 291, in close_session
      data = self._uasocket.send_request(request)
    File "C:\Users\chma02\AppData\Roaming\Python\Python37\site-packages\opcua\client\ua_client.py", line 76, in send_request
      future = self._send_request(request, callback, timeout, message_type)
    File "C:\Users\chma02\AppData\Roaming\Python\Python37\site-packages\opcua\client\ua_client.py", line 67, in _send_request
      self._socket.write(msg)
    File "C:\Users\chma02\AppData\Roaming\Python\Python37\site-packages\opcua\common\utils.py", line 118, in write
      self.socket.sendall(data)
  OSError: [WinError 10038] An operation was attempted on something that is not a socket</p>
  
  <p>During handling of the above exception, another exception occurred:</p>
  
  <p>Traceback (most recent call last):
    File "C:/my files/python files/SMSPLCSIMULATIONV2-master (1)/SMSPLCSIMULATIONV2-master/clientcomm_v1.py", line 92, in 
      comm.opc_client_connect()
    File "C:/my files/python files/SMSPLCSIMULATIONV2-master (1)/SMSPLCSIMULATIONV2-master/clientcomm_v1.py", line 45, in opc_client_connect
      self.client.disconnect()
    File "C:\Users\chma02\AppData\Roaming\Python\Python37\site-packages\opcua\client\client.py", line 274, in disconnect
      self.disconnect_socket()
    File "C:\Users\chma02\AppData\Roaming\Python\Python37\site-packages\opcua\client\client.py", line 283, in disconnect_socket
      self.uaclient.disconnect_socket()
    File "C:\Users\chma02\AppData\Roaming\Python\Python37\site-packages\opcua\client\ua_client.py", line 248, in disconnect_socket</p>
  
  <pre><code>return self._uasocket.disconnect_socket()
  </code></pre>
  
  <p>File "C:\Users\chma02\AppData\Roaming\Python\Python37\site-packages\opcua\client\ua_client.py", line 154, in disconnect_socket
      self._socket.socket.shutdown(socket.SHUT_RDWR)
  OSError: [WinError 10038] An operation was attempted on something that is not a socket</p>