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
Show 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):
...
@@ -79,7 +79,7 @@ class Client(object):
which offers the raw OPC-UA services interface.
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.
:param url: url of the server.
...
@@ -101,7 +101,7 @@ class Client(object):
...
@@ -101,7 +101,7 @@ class Client(object):
self
.
secure_channel_timeout
=
3600000
# 1 hour
self
.
secure_channel_timeout
=
3600000
# 1 hour
self
.
session_timeout
=
3600000
# 1 hour
self
.
session_timeout
=
3600000
# 1 hour
self
.
_policy_ids
=
[]
self
.
_policy_ids
=
[]
self
.
uaclient
=
UaClient
(
timeout
,
socket_timeout
)
self
.
uaclient
=
UaClient
(
timeout
)
self
.
user_certificate
=
None
self
.
user_certificate
=
None
self
.
user_private_key
=
None
self
.
user_private_key
=
None
self
.
_session_counter
=
1
self
.
_session_counter
=
1
...
...
opcua/client/ua_client.py
View file @
cb034f5f
...
@@ -18,12 +18,11 @@ class UASocketClient(object):
...
@@ -18,12 +18,11 @@ class UASocketClient(object):
handle socket connection and send ua messages
handle socket connection and send ua messages
timeout is the timeout used while waiting for an ua answer from server
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
.
logger
=
logging
.
getLogger
(
__name__
+
".Socket"
)
self
.
_thread
=
None
self
.
_thread
=
None
self
.
_lock
=
Lock
()
self
.
_lock
=
Lock
()
self
.
timeout
=
timeout
self
.
timeout
=
timeout
self
.
socket_timeout
=
socket_timeout
self
.
_socket
=
None
self
.
_socket
=
None
self
.
_do_stop
=
False
self
.
_do_stop
=
False
self
.
authentication_token
=
ua
.
NodeId
()
self
.
authentication_token
=
ua
.
NodeId
()
...
@@ -133,7 +132,7 @@ class UASocketClient(object):
...
@@ -133,7 +132,7 @@ class UASocketClient(object):
connect to server socket and start receiving thread
connect to server socket and start receiving thread
"""
"""
self
.
logger
.
info
(
"opening connection"
)
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
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
.
_socket
=
utils
.
SocketWrapper
(
sock
)
self
.
start
()
self
.
start
()
...
@@ -195,12 +194,11 @@ class UaClient(object):
...
@@ -195,12 +194,11 @@ class UaClient(object):
uaprotocol_auto.py and uaprotocol_hand.py available under opcua.ua
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__
)
self
.
logger
=
logging
.
getLogger
(
__name__
)
# _publishcallbacks should be accessed in recv thread only
# _publishcallbacks should be accessed in recv thread only
self
.
_publishcallbacks
=
{}
self
.
_publishcallbacks
=
{}
self
.
_timeout
=
timeout
self
.
_timeout
=
timeout
self
.
_socket_timeout
=
socket_timeout
self
.
_uasocket
=
None
self
.
_uasocket
=
None
self
.
_security_policy
=
ua
.
SecurityPolicy
()
self
.
_security_policy
=
ua
.
SecurityPolicy
()
...
@@ -211,7 +209,7 @@ class UaClient(object):
...
@@ -211,7 +209,7 @@ class UaClient(object):
"""
"""
connect to server socket and start receiving thread
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
)
return
self
.
_uasocket
.
connect_socket
(
host
,
port
)
def
disconnect_socket
(
self
):
def
disconnect_socket
(
self
):
...
...
opcua/common/utils.py
View file @
cb034f5f
...
@@ -4,7 +4,6 @@ from concurrent.futures import Future
...
@@ -4,7 +4,6 @@ from concurrent.futures import Future
import
functools
import
functools
import
threading
import
threading
from
socket
import
error
as
SocketError
from
socket
import
error
as
SocketError
from
socket
import
timeout
as
SocketTimeout
try
:
try
:
# we prefer to use bundles asyncio version, otherwise fallback to trollius
# we prefer to use bundles asyncio version, otherwise fallback to trollius
...
@@ -30,10 +29,6 @@ class SocketClosedException(UaError):
...
@@ -30,10 +29,6 @@ class SocketClosedException(UaError):
pass
pass
class
SocketTimeoutException
(
UaError
):
pass
class
Buffer
(
object
):
class
Buffer
(
object
):
"""
"""
...
@@ -107,8 +102,6 @@ class SocketWrapper(object):
...
@@ -107,8 +102,6 @@ class SocketWrapper(object):
while
size
>
0
:
while
size
>
0
:
try
:
try
:
chunk
=
self
.
socket
.
recv
(
size
)
chunk
=
self
.
socket
.
recv
(
size
)
except
SocketTimeout
as
ex
:
raise
SocketTimeoutException
(
"Server socket has timed out"
)
except
(
OSError
,
SocketError
)
as
ex
:
except
(
OSError
,
SocketError
)
as
ex
:
raise
SocketClosedException
(
"Server socket has closed"
,
ex
)
raise
SocketClosedException
(
"Server socket has closed"
,
ex
)
if
not
chunk
:
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