Comments (9)
Hello,
Could you please provide more details about the issue, also how you are running the client and server.
Thank you.
from lib60870.net.
Hi again.
I use Axon Test software as RTU(Server) IEC104 simulator.
This is my Connect method body:
con = new Connection(IPTextBox.Text, Convert.ToInt32(PortTextBox.Text));
con.DebugOutput = true;
con.SetASDUReceivedHandler(asduReceivedHandler, null);
con.SetConnectionHandler(ConnectionHandler, null);
try
{
con.Connect();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
and I do something in ASDURecieveHandler.
everything is OK. But when I click on Disconnect Button my form run ino Hang.
This is my Disconnect method body:
try
{
con.Close();
}
catch (Exception ex)
{
MessageBox.Show("Close Connection Error : " + Environment.NewLine + ex.ToString(), "Close Connection Error");
}
I changed my code and now my Disconnect method body is like this:
try
{
con.Cancel();
con.Close();
}
catch (Exception ex)
{
MessageBox.Show("Close Connection Error : " + Environment.NewLine + ex.ToString(), "Close Connection Error");
}
and now it is OK. Should I call con.Cancel() before con.Close() ? I saw Cancel method close the Socket and because of this, I called Cancel() method before Close(). Did I do correct way?
from lib60870.net.
Your call to Close() is not within the ASDURecieveHandler, right? I guess that would cause a deadlock. But calling Cancel() should not help in that case.
I don't think that you are supposed to call Cancel() before Close(), but that might still be a viable workaround.
I'm not sure if the way "running = false" is set in one thread to signal another thread to stop is correct without any synchronization.
from lib60870.net.
Yes. That's right. I call Close() Method in button_Click event, not in ASDURecieverHandler.
So, how can I Close the connection in IEC104 Client? I sometimes need to disconnect my client.
What solution do you suggest?
from lib60870.net.
First you need to ensure that the connection object is not null before attempting to close it.
if (con != null)
What you can try then is calling the Disconnect() method, or maybe after calling Close() or Disconnect() you can call Dispose() this dispose of the connection object after closing it.
from lib60870.net.
Disconnect()? I can't find Disconnect method.
I can call Dispose() as long as Close() method completes. But the problem is that it does not come out of Close() method.
from lib60870.net.
Since the issue is coming from workerThread.Join(); You can put a condition that will wait for the worker thread to finish within a specified timeout. If the thread does not finish within the timeout, it will close the connection.
from lib60870.net.
Could it be that the connection thread is stuck in the connection handler? When you are calling the UI in the connection handler then it could be a deadlock because the workerThread.Join is also running in the UI thread.
from lib60870.net.
Hi.
I changed my code and moved my connect and disconnect method into another thread (Background worker) and my problem solved.
Thanks a lot.
from lib60870.net.
Related Issues (20)
- Wrong encoding of negative ScaledValue HOT 1
- [Ask] SBO command (bool select = true) HOT 1
- SendCommand HOT 1
- Checking validity of TestCommand HOT 1
- Extra code for operation "remove confirmed messages from list" (ClientConnection)
- How to handle select-before-execute in a server? HOT 2
- how to read parameter data from ASDUReceivedHandler ?
- how to clear ASDUReceivedHandler ?? HOT 1
- Talos Security Advisory for MZ Automation GmbH HOT 1
- Send Invalid Message to Master HOT 1
- socketError=true without lastException value causing NullReference object
- Maintain ClientConnection after "Failed to parse ASDU"
- There is no method or property to check IEC104 Server is running or not HOT 3
- Exception when call Server.Stop() HOT 1
- 104server Received sequence number out of range HOT 2
- SocketException error codes are not OS specific
- IEC60870_5_104_MAX_ASDU_LENGTH (Questions) HOT 1
- Reading data HOT 1
- IEC 104 Client connecting to 100s of devices HOT 1
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 lib60870.net.