-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The adapter isn't closing when the agent connession is missing #6
Comments
The problem is in the mListenThread thread which calls the TcpListener.AcceptTcpListenerClient method that as reported on the Microsoft official documentation (https://docs.microsoft.com/en-US/dotnet/api/system.net.sockets.tcplistener.accepttcpclient?view=netframework-4.8) is a blocking call, so when the agent is missing the thread is blocked and never ending. The 20-second delay is caused by the Thread.Join method with a timeout of 20000ms called by the adapter Stop method; since the mListenThread is never ending the timeout is fully consumed and the execution continues. |
You should change to catch the exception since agent is out and the tcp will throw an error. |
This is sample code and we appreciate the feedback.
Please create a fork and send a pull request when you find a solution. Any contributions are greatly appreciated.
Thanks!
Will
(Sent from mobile)
… On Mar 9, 2020, at 08:30, lcicala ***@***.***> wrote:
The problem is in the mListenThread thread which calls the TcpListener.AcceptTcpListenerClient method that as reported on the Microsoft official documentation (https://docs.microsoft.com/en-US/dotnet/api/system.net.sockets.tcplistener.accepttcpclient?view=netframework-4.8) is a blocking call, so when the agent is missing the thread is blocked and never ending. The 20-second delay is caused by the Thread.Join method with a timeout of 20000ms called by the adapter Stop method; since the mListenThread is never ending the timeout is fully consumed and the execution continues.
In order to fix this issue the TcpListener.AcceptTcpClient call will be executed only when there are pending requests.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
The mListenThread.AcceptTcpClient call is executed only if the mListenThread.Pending returns true in order to prevent the blocking call Closes mtconnect#6
I've pushed a version that fixes this issue. |
When the Stop method is called on an instance of the adapter there is a 20-second delay before continuing. After that the application continue running until its closing, but a library thread continue running and it doesn't allow the application to close completely, this issue does not permit the application to run again until the thread is killed by the task manager. This issue is only noticeable when the agent is missing.
The text was updated successfully, but these errors were encountered: