Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
opcua-asyncio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nikola Balog
opcua-asyncio
Commits
cb034f5f
Commit
cb034f5f
authored
Oct 10, 2016
by
olivier R-D
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Prevent the UASocketClient from hanging (#316)"
This reverts commit
3f750a92
.
parent
77ec2c1a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
15 deletions
+6
-15
opcua/client/client.py
opcua/client/client.py
+2
-2
opcua/client/ua_client.py
opcua/client/ua_client.py
+4
-6
opcua/common/utils.py
opcua/common/utils.py
+0
-7
No files found.
opcua/client/client.py
View file @
cb034f5f
...
...
@@ -79,7 +79,7 @@ class Client(object):
which offers the raw OPC-UA services interface.
"""
def
__init__
(
self
,
url
,
timeout
=
4
,
socket_timeout
=
10
):
def
__init__
(
self
,
url
,
timeout
=
4
):
"""
:param url: url of the server.
...
...
@@ -101,7 +101,7 @@ class Client(object):
self
.
secure_channel_timeout
=
3600000
# 1 hour
self
.
session_timeout
=
3600000
# 1 hour
self
.
_policy_ids
=
[]
self
.
uaclient
=
UaClient
(
timeout
,
socket_timeout
)
self
.
uaclient
=
UaClient
(
timeout
)
self
.
user_certificate
=
None
self
.
user_private_key
=
None
self
.
_session_counter
=
1
...
...
opcua/client/ua_client.py
View file @
cb034f5f
...
...
@@ -18,12 +18,11 @@ class UASocketClient(object):
handle socket connection and send ua messages
timeout is the timeout used while waiting for an ua answer from server
"""
def
__init__
(
self
,
timeout
=
1
,
security_policy
=
ua
.
SecurityPolicy
()
,
socket_timeout
=
10
):
def
__init__
(
self
,
timeout
=
1
,
security_policy
=
ua
.
SecurityPolicy
()):
self
.
logger
=
logging
.
getLogger
(
__name__
+
".Socket"
)
self
.
_thread
=
None
self
.
_lock
=
Lock
()
self
.
timeout
=
timeout
self
.
socket_timeout
=
socket_timeout
self
.
_socket
=
None
self
.
_do_stop
=
False
self
.
authentication_token
=
ua
.
NodeId
()
...
...
@@ -133,7 +132,7 @@ class UASocketClient(object):
connect to server socket and start receiving thread
"""
self
.
logger
.
info
(
"opening connection"
)
sock
=
socket
.
create_connection
((
host
,
port
)
,
timeout
=
self
.
socket_timeout
)
sock
=
socket
.
create_connection
((
host
,
port
))
sock
.
setsockopt
(
socket
.
IPPROTO_TCP
,
socket
.
TCP_NODELAY
,
1
)
# nodelay ncessary to avoid packing in one frame, some servers do not like it
self
.
_socket
=
utils
.
SocketWrapper
(
sock
)
self
.
start
()
...
...
@@ -195,12 +194,11 @@ class UaClient(object):
uaprotocol_auto.py and uaprotocol_hand.py available under opcua.ua
"""
def
__init__
(
self
,
timeout
=
1
,
socket_timeout
=
10
):
def
__init__
(
self
,
timeout
=
1
):
self
.
logger
=
logging
.
getLogger
(
__name__
)
# _publishcallbacks should be accessed in recv thread only
self
.
_publishcallbacks
=
{}
self
.
_timeout
=
timeout
self
.
_socket_timeout
=
socket_timeout
self
.
_uasocket
=
None
self
.
_security_policy
=
ua
.
SecurityPolicy
()
...
...
@@ -211,7 +209,7 @@ class UaClient(object):
"""
connect to server socket and start receiving thread
"""
self
.
_uasocket
=
UASocketClient
(
self
.
_timeout
,
security_policy
=
self
.
_security_policy
,
socket_timeout
=
self
.
_socket_timeout
)
self
.
_uasocket
=
UASocketClient
(
self
.
_timeout
,
security_policy
=
self
.
_security_policy
)
return
self
.
_uasocket
.
connect_socket
(
host
,
port
)
def
disconnect_socket
(
self
):
...
...
opcua/common/utils.py
View file @
cb034f5f
...
...
@@ -4,7 +4,6 @@ from concurrent.futures import Future
import
functools
import
threading
from
socket
import
error
as
SocketError
from
socket
import
timeout
as
SocketTimeout
try
:
# we prefer to use bundles asyncio version, otherwise fallback to trollius
...
...
@@ -30,10 +29,6 @@ class SocketClosedException(UaError):
pass
class
SocketTimeoutException
(
UaError
):
pass
class
Buffer
(
object
):
"""
...
...
@@ -107,8 +102,6 @@ class SocketWrapper(object):
while
size
>
0
:
try
:
chunk
=
self
.
socket
.
recv
(
size
)
except
SocketTimeout
as
ex
:
raise
SocketTimeoutException
(
"Server socket has timed out"
)
except
(
OSError
,
SocketError
)
as
ex
:
raise
SocketClosedException
(
"Server socket has closed"
,
ex
)
if
not
chunk
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment