Comments (8)
ok . Now I think I understand. The server break the connection and sends an
incomplete packet. I will have a look if I can add a try catch around that
or raise the exception in client thread
On Fri, 7 Aug 2015 at 16:03 Olivier Roulet-Dubonnet <
[email protected]> wrote:
Obviously when I restart a server here I do not get that kind of error.
Kan you send me a reproductible scenario?On Fri, 7 Aug 2015 at 16:01 kashp [email protected] wrote:
yes when you restart OPC server
On Client side these error started, I want to re initialize connection
but due to absence of raise condition i can not handle any Broken
connection exceptionI also received
Traceback (most recent call last):
File "/home/kashp/PycharmProjects/gor_flip/OpcuaConnection.py", line 42,
in write_tag
var = self.root.get_child(["0:Objects", read_path])
File "/home/kashp/PycharmProjects/gor_flip/opcua/node.py", line 290, in
get_child
result = self.server.translate_browsepaths_to_nodeids([bpath])
File "/home/kashp/PycharmProjects/gor_flip/opcua/binary_client.py", line
292, in translate_browsepaths_to_nodeids
data = self._send_request(request)
File "/home/kashp/PycharmProjects/gor_flip/opcua/binary_client.py", line
60, in _send_request
self._write_socket(hdr, symhdr, seqhdr, request)
File "/home/kashp/PycharmProjects/gor_flip/opcua/binary_client.py", line
141, in _write_socket
self._socket.write(alle)
File "/home/kashp/PycharmProjects/gor_flip/opcua/utils.py", line 88, in
write
self.socket.sendall(data)
BrokenPipeError: [Errno 32] Broken pipeTraceback (most recent call last):
File "/home/kashp/PycharmProjects/gor_flip/OpcuaConnection.py", line 43,
in write_tag
var.set_value(dv)
File "/home/kashp/PycharmProjects/gor_flip/opcua/node.py", line 187, in
set_value
self.set_attribute(ua.AttributeIds.Value, datavalue)
File "/home/kashp/PycharmProjects/gor_flip/opcua/node.py", line 200, in
set_attribute
result[0].check()
File "/home/kashp/PycharmProjects/gor_flip/opcua/uatypes.py", line 249,
in check
raise Exception("{}({})".format(self.doc, self.name))
Exception: The node id refers to a node that does not exist in the server
address space.(BadNodeIdUnknown)—
Reply to this email directly or view it on GitHub
#21 (comment)
.
from python-opcua.
Do you have a reproductiblr scénario or is it à one time event?
On Fri, Aug 7, 2015, 14:28 kashp [email protected] wrote:
Hi
When Opc server restarted i got the following issueFile "/usr/local/lib/python3.4/concurrent/futures/_base.py", line 297, in
_invoke_callbacks
callback(self)
File "/home/kashp/PycharmProjects/gor_flip/opcua/binary_client.py", line
328, in _call_publish_callback
response = ua.PublishResponse.from_binary(future.result())
File "/home/kashp/PycharmProjects/gor_flip/opcua/uaprotocol_auto.py", line
10434, in from_binary
obj.Parameters = PublishResult.from_binary(data)
File "/home/kashp/PycharmProjects/gor_flip/opcua/uaprotocol_auto.py", line
10383, in from_binary
obj.SubscriptionId = unpack_uatype('UInt32', data)
File "/home/kashp/PycharmProjects/gor_flip/opcua/uatypes.py", line 135, in
unpack_uatype
return struct.unpack(fmt, data.read(size))[0]
File "/home/kashp/PycharmProjects/gor_flip/opcua/utils.py", line 39, in
read
raise Exception("No enough data left in buffer, request for {}, we have
{}".format(size, self))
Exception: No enough data left in buffer, request for 4, we have
Buffer(size:0, data:b'')—
Reply to this email directly or view it on GitHub
#21.
from python-opcua.
yes when you restart OPC server
On Client side these error started, I want to re initialize connection but due to absence of raise condition i can not handle any Broken connection exception
I also received
Traceback (most recent call last):
File "/home/kashp/PycharmProjects/gor_flip/OpcuaConnection.py", line 42, in write_tag
var = self.root.get_child(["0:Objects", read_path])
File "/home/kashp/PycharmProjects/gor_flip/opcua/node.py", line 290, in get_child
result = self.server.translate_browsepaths_to_nodeids([bpath])
File "/home/kashp/PycharmProjects/gor_flip/opcua/binary_client.py", line 292, in translate_browsepaths_to_nodeids
data = self._send_request(request)
File "/home/kashp/PycharmProjects/gor_flip/opcua/binary_client.py", line 60, in _send_request
self._write_socket(hdr, symhdr, seqhdr, request)
File "/home/kashp/PycharmProjects/gor_flip/opcua/binary_client.py", line 141, in _write_socket
self._socket.write(alle)
File "/home/kashp/PycharmProjects/gor_flip/opcua/utils.py", line 88, in write
self.socket.sendall(data)
BrokenPipeError: [Errno 32] Broken pipe
Traceback (most recent call last):
File "/home/kashp/PycharmProjects/gor_flip/OpcuaConnection.py", line 43, in write_tag
var.set_value(dv)
File "/home/kashp/PycharmProjects/gor_flip/opcua/node.py", line 187, in set_value
self.set_attribute(ua.AttributeIds.Value, datavalue)
File "/home/kashp/PycharmProjects/gor_flip/opcua/node.py", line 200, in set_attribute
result[0].check()
File "/home/kashp/PycharmProjects/gor_flip/opcua/uatypes.py", line 249, in check
raise Exception("{}({})".format(self.doc, self.name))
Exception: The node id refers to a node that does not exist in the server address space.(BadNodeIdUnknown)
from python-opcua.
Obviously when I restart a server here I do not get that kind of error. Kan
you send me a reproductible scenario?
On Fri, 7 Aug 2015 at 16:01 kashp [email protected] wrote:
yes when you restart OPC server
On Client side these error started, I want to re initialize connection but
due to absence of raise condition i can not handle any Broken connection
exceptionI also received
Traceback (most recent call last):
File "/home/kashp/PycharmProjects/gor_flip/OpcuaConnection.py", line 42,
in write_tag
var = self.root.get_child(["0:Objects", read_path])
File "/home/kashp/PycharmProjects/gor_flip/opcua/node.py", line 290, in
get_child
result = self.server.translate_browsepaths_to_nodeids([bpath])
File "/home/kashp/PycharmProjects/gor_flip/opcua/binary_client.py", line
292, in translate_browsepaths_to_nodeids
data = self._send_request(request)
File "/home/kashp/PycharmProjects/gor_flip/opcua/binary_client.py", line
60, in _send_request
self._write_socket(hdr, symhdr, seqhdr, request)
File "/home/kashp/PycharmProjects/gor_flip/opcua/binary_client.py", line
141, in _write_socket
self._socket.write(alle)
File "/home/kashp/PycharmProjects/gor_flip/opcua/utils.py", line 88, in
write
self.socket.sendall(data)
BrokenPipeError: [Errno 32] Broken pipeTraceback (most recent call last):
File "/home/kashp/PycharmProjects/gor_flip/OpcuaConnection.py", line 43,
in write_tag
var.set_value(dv)
File "/home/kashp/PycharmProjects/gor_flip/opcua/node.py", line 187, in
set_value
self.set_attribute(ua.AttributeIds.Value, datavalue)
File "/home/kashp/PycharmProjects/gor_flip/opcua/node.py", line 200, in
set_attribute
result[0].check()
File "/home/kashp/PycharmProjects/gor_flip/opcua/uatypes.py", line 249, in
check
raise Exception("{}({})".format(self.doc, self.name))
Exception: The node id refers to a node that does not exist in the server
address space.(BadNodeIdUnknown)—
Reply to this email directly or view it on GitHub
#21 (comment)
.
from python-opcua.
And I had one more look.....
There is no point in raising in exception there, this happens in a callback from the server. you have no method call where to raise an exception.
We could set a flag in the library but I am unsure if this is a good solution. you would nee to poll that flag....
I think if you want to detect if the connection is lost the best thing to do is to read a node value on the server at a given frequence. If the connection is lost an exception will read and you can restart client
from python-opcua.
thanks oroultet
I decided to restart application from supervisord on getting read or write error
But my application doesn't exit on restart the server.
Please help. I am confused how to handle this siutuation
try:
client = Client("opc.tcp://192.168.190.129:49320")
client.connect()
root = client.get_root_node()
state = root.get_child(["0:Objects", "2:Simulation.Warehouse.Scanner.PKG_W_DATA[1,1]"])
fast = root.get_child(["Objects", "2:Simulation.Warehouse.Scanner.PKG_C_DATA[1,1]"])
handler = SubHandler()
count=1
while(1):
f.flush()
dv_id = ua.DataValue(ua.Variant(randint(1,10000), ua.VariantType.UInt16))
dv_data = ua.DataValue(ua.Variant(randint(1,10000), ua.VariantType.UInt16))
try:
state.set_value(dv_id)
fast.set_value(dv_data)
print (state.get_value(),fast.get_value())
except:
print("unable to read")
exit()
print ("count",count)
count=count+1
time.sleep(4)
except:
print("error")
exit()
from python-opcua.
I guess the keepalive thread is still running. call client.keepalive.stop()
then stop.
Does it work?
I do not see how to do this automatically in library.
Thanks for your help discovering all these things :-)
On Sat, 8 Aug 2015 at 09:12 kashp [email protected] wrote:
thanks oroultet
I decided to restart application from supervisord on getting read or write
errorBut my application doesn't exit on restart the server.
Please help. I am confused how to handle this siutuation
try:
client = Client("opc.tcp://192.168.190.129:49320")
client.connect()
root = client.get_root_node()
state = root.get_child(["0:Objects",
"2:Simulation.Warehouse.Scanner.PKG_W_DATA[1,1]"])
fast = root.get_child(["Objects",
"2:Simulation.Warehouse.Scanner.PKG_C_DATA[1,1]"])
handler = SubHandler()count=1 while(1): f.flush() dv_id = ua.DataValue(ua.Variant(randint(1,10000), ua.VariantType.UInt16)) dv_data = ua.DataValue(ua.Variant(randint(1,10000), ua.VariantType.UInt16)) try: state.set_value(dv_id) fast.set_value(dv_data) print (state.get_value(),fast.get_value()) except: print("unable to read") exit() print ("count",count) count=count+1 time.sleep(4) except: print("error") exit()
—
Reply to this email directly or view it on GitHub
#21 (comment)
.
from python-opcua.
Thanks for your help now i am able to exit the program, now i can restart the application in case of server failure.
:)
from python-opcua.
Related Issues (20)
- Getting "BadSecurityChecksFailed" every few minutes for constant read requests HOT 2
- Problem with set value in OPC UA S7-1200 HOT 7
- Unable to subscribe to datachange when using Datavalue
- UA-Client reconciliate subscription not working HOT 4
- Duplicate endpoint when restarting server
- Cannot get value from alias HOT 14
- python OPCUA package installation failed in Linux ARM32V7 HOT 4
- Continues connection to opc ua - kepserver, and flask rest api HOT 1
- Callback function or event to intercept a write request on server
- How to use method call in client with complex arguments HOT 14
- Transfer Subscription Request
- SourceTime Stamp Issue HOT 1
- My simple python server error
- Unable to change variable value to True HOT 12
- Writing variables to ABB IRC5 controller using set_value() function HOT 4
- AttributeError: 'bytearray' object has no attribute 'public_key' HOT 7
- Disconnection of server session after 1 minute-TimeoutError
- Timeout error
- How to get node value HOT 4
- Triggering DataChangeEvent Only When Variant Value Changes HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-opcua.