Skip to content
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

Client connections leaked #3

Open
GoogleCodeExporter opened this issue May 12, 2015 · 1 comment
Open

Client connections leaked #3

GoogleCodeExporter opened this issue May 12, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

It appears that the library is leaking connection objects, leading to the 
eventual grind to a halt of the Arduino, which can only be fixed by a reboot.

I have a proposed solution, but I can't test it because I don't have modbus 
here. The colleague I researched this for does, but it will be a while before 
he returns to his home country to test it and tell me how it went. I wrote this 
based on the Arduino documentation, which says this: "The connection persists 
when the returned client object goes out of scope; you can close it by calling 
client.stop()."

Proposed solution:

diff --git a/Mudbus/Mudbus.cpp b/Mudbus/Mudbus.cpp
index 5c5356c..9340b02 100755
--- a/Mudbus/Mudbus.cpp
+++ b/Mudbus/Mudbus.cpp
@@ -36,6 +36,11 @@ void Mudbus::Run()
   // Client client = MbServer.available();
   // For Arduino 1.0
   EthernetClient client = MbServer.available();
+  if(!client.connected())
+  {
+    client.stop();
+    return;
+  }
   if(client.available())
   {
     Reads = 1 + Reads * (Reads < 999);

Original issue reported on code.google.com by [email protected] on 18 Sep 2014 at 4:02

@GoogleCodeExporter
Copy link
Author

hi,
I have tested your solution! Working fine!
The leaking problem dissapeared.
Thanks

Original comment by [email protected] on 19 Jan 2015 at 7:10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant