Thread Error:OSError: [WinError 10038] 在一个非套接字上尝试了一个操作 #848
Replies: 6 comments 1 reply
-
again:
"WinError 10038" is not a OPC UA Error! what i see in your code is you create connections in a while loop each 100ms a new one... this looks like a DDoS-Script for OPC UA Servers ^^ we provide a lot of examples: https://github.com/FreeOpcUa/opcua-asyncio/tree/master/examples |
Beta Was this translation helpful? Give feedback.
-
thanks again, I want use threading to move data at same time. |
Beta Was this translation helpful? Give feedback.
-
change :time.sleep(1) |
Beta Was this translation helpful? Give feedback.
-
new message: |
Beta Was this translation helpful? Give feedback.
-
I would recommened:
|
Beta Was this translation helpful? Give feedback.
-
Hi,I fixed this problem .when I try to read the data ,it will be connect the sever,EVERYTIME! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Good afternoon,I'm come form china
I wrote the code below:
``from opcua import Client
import time
from threading import Thread
import queue
work = queue.Queue(1000)
client = Client("opc.tcp://127.0.0.1:49320")
def task1(): # 定义任务1
try:
while 1:
client.connect()
T = client.get_node('ns=2;s=test.mac.TA1').get_value()
work.put(T)
time.sleep(0.1)
except Exception as e:
print(e)
finally:
client.disconnect()
def task2():
while 1:
time.sleep(0.5)
print(work.get())
def main(): # 定义main函数
t1 = Thread(target=task1) # 定义线程t1,线程任务为调用task1函数,task1函数的参数是6
t2 = Thread(target=task2) # 定义线程t2,线程任务为调用task2函数,task2函数无参数
t1.start() # 开始运行t1线程
t2.start() # 开始运行t2线程
if name == 'main':
main() # 调用main函数`
Error Meessage:
Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Users\chenh\AppData\Local\Programs\Python\Python39\lib\site-packages\opcua\client\client.py", line 299, in disconnect
self.close_secure_channel()
File "C:\Users\chenh\AppData\Local\Programs\Python\Python39\lib\site-packages\opcua\client\client.py", line 343, in close_secure_channel
return self.uaclient.close_secure_channel()
File "C:\Users\chenh\AppData\Local\Programs\Python\Python39\lib\site-packages\opcua\client\ua_client.py", line 282, in close_secure_channel
return self._uasocket.close_secure_channel()
File "C:\Users\chenh\AppData\Local\Programs\Python\Python39\lib\site-packages\opcua\client\ua_client.py", line 223, in close_secure_channel
future = self._send_request(request, message_type=ua.MessageType.SecureClose)
File "C:\Users\chenh\AppData\Local\Programs\Python\Python39\lib\site-packages\opcua\client\ua_client.py", line 72, in _send_request
self._socket.write(msg)
File "C:\Users\chenh\AppData\Local\Programs\Python\Python39\lib\site-packages\opcua\common\utils.py", line 118, in write
self.socket.sendall(data)
OSError: [WinError 10038] 在一个非套接字上尝试了一个操作。`
How can i fix it?
Now in china,many engineer want use Python in electric design.
But only some people use FreeOpcUA in CSDN
No one knows haw to use it in internet
Beta Was this translation helpful? Give feedback.
All reactions