[Beremiz-devel] PLC crashes some times due to "Bind(): Address already in use" when using Modbus server node

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[Beremiz-devel] PLC crashes some times due to "Bind(): Address already in use" when using Modbus server node

Wisse Hooghiem
Hi again,

We have been using the beremiz editor, and runtime for over a year now without any big problems. After updating to the latest source from bitbucket a few weeks ago, sometimes the PLC crashes due to a "bind address already in use error"
The situation is as follows, we have a Beremiz_runtime running inside a docker container (ubuntu 16.04). This container is running on some server.
we recently updated the container with the latest source from bitbucket (adding BACnet support to the systems) since this new container
sometimes the plc crashes and gives the following error:

Starting_error.png

I have a hard time figuring out when exactly the error occur's
sometimes it happens after:
- rebuild->stop->transfer->run
- or after stop->run
- or after stop->re transfer (without new build) -> run.

anyhow it causes the plc to crash and the only way to fix it is to restart the docker container
which in turn restarts the beremiz service.
the logs off the plc say that it has something to do with the Modbus server node see image below:
Beremiz_bind_error.png


I discovered this problem when testing a project which has a BACnet and Modbus server.
the only thing that happens is 2 numbers getting added on both protocol's


I think that sometimes the Modbus server doesn't close it's socket and then on restarting the plc the runtime tries to start a new server when the other one still exists somewhere. I looked in the code of the modbus runtime
but i couldn't figure out where or if the server gets closed.
I would love to fix this problem myself thus learning more about the code but any pointers in the right direction are much appreciated.
Could also be a problem somewhere else.

if more info is needed please let me know.

Met vriendelijke groet/ Kind regards, 

Wisse Hooghiem

Advanced Climate Systems bv | +31 (0)85 200 39 89 | P.O. Box 5241 |NL- 2000 CE  Haarlem| Wilhelminastraat 51 | NL-2011 VL | Haarlem



_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel

image001.png (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Beremiz-devel] PLC crashes some times due to "Bind(): Address already in use" when using Modbus server node

Beremiz-Devel mailing list

 Hi Wisse,


 
On Wednesday, April 10, 2019 15:39:38 Wisse Hooghiem wrote:

> Hi again,
>
> We have been using the beremiz editor, and runtime for over a year now
> without any big problems. After updating to the latest source from
> bitbucket a few weeks ago, sometimes the PLC crashes due to a "bind address
> already in use error"
> The situation is as follows, we have a Beremiz_runtime running inside a
> docker container (ubuntu 16.04). This container is running on some server.
> we recently updated the container with the latest source from bitbucket
> (adding BACnet support to the systems) since this new container
> sometimes the plc crashes and gives the following error:
>
> [image: Starting_error.png]
>
> I have a hard time figuring out when exactly the error occur's
> sometimes it happens after:
> - rebuild->stop->transfer->run
> - or after stop->run
> - or after stop->re transfer (without new build) -> run.
>
> anyhow it causes the plc to crash and the only way to fix it is to restart
> the docker container
> which in turn restarts the beremiz service.
> the logs off the plc say that it has something to do with the Modbus server
> node see image below:
> [image: Beremiz_bind_error.png]
>
>
> I discovered this problem when testing a project which has a BACnet and
> Modbus server.
> the only thing that happens is 2 numbers getting added on both protocol's
>
>
> I think that sometimes the Modbus server doesn't close it's socket and then
> on restarting the plc the runtime tries to start a new server when the
> other one still exists somewhere. I looked in the code of the modbus runtime
> but i couldn't figure out where or if the server gets closed.


 The Modbus socket gets closed in the library that implements the modbus
stack...
 
 Details:
------------
 Upon PLC shutdown, the LC code should call the Modbus plugin's __cleanup()
function, which calls the modbus library's
mb_slave_close()      (if running as server)
or
mb_master_close()   (if running as client)

 As I said, these functions are implemented in the modbus library.
 This library will eventually call the layer1
modbus_close()

 Which for modbus TCP is actually a pointer to function
modbus_tcp_close()


 This will eventually call
close_connection()   (in mb_tcp.c file)
 which will actually close the socket.


   Let me know if you figure out what is happening and if anything needs to be
fixed.



  Cheers,

        Mario.


_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Beremiz-devel] PLC crashes some times due to "Bind(): Address already in use" when using Modbus server node

Edouard Tisserant
Hello,

I fixed it already a few weeks ago, I forgot to publish :

https://hg.beremiz.org/Modbus/rev/1223f413e054

@Mario : please pull

Edouard


On 10/04/2019 16:48, Mario de Sousa via Beremiz-devel wrote:

>  Hi Wisse,
>
>
>  
> On Wednesday, April 10, 2019 15:39:38 Wisse Hooghiem wrote:
>> Hi again,
>>
>> We have been using the beremiz editor, and runtime for over a year now
>> without any big problems. After updating to the latest source from
>> bitbucket a few weeks ago, sometimes the PLC crashes due to a "bind address
>> already in use error"
>> The situation is as follows, we have a Beremiz_runtime running inside a
>> docker container (ubuntu 16.04). This container is running on some server.
>> we recently updated the container with the latest source from bitbucket
>> (adding BACnet support to the systems) since this new container
>> sometimes the plc crashes and gives the following error:
>>
>> [image: Starting_error.png]
>>
>> I have a hard time figuring out when exactly the error occur's
>> sometimes it happens after:
>> - rebuild->stop->transfer->run
>> - or after stop->run
>> - or after stop->re transfer (without new build) -> run.
>>
>> anyhow it causes the plc to crash and the only way to fix it is to restart
>> the docker container
>> which in turn restarts the beremiz service.
>> the logs off the plc say that it has something to do with the Modbus server
>> node see image below:
>> [image: Beremiz_bind_error.png]
>>
>>
>> I discovered this problem when testing a project which has a BACnet and
>> Modbus server.
>> the only thing that happens is 2 numbers getting added on both protocol's
>>
>>
>> I think that sometimes the Modbus server doesn't close it's socket and then
>> on restarting the plc the runtime tries to start a new server when the
>> other one still exists somewhere. I looked in the code of the modbus runtime
>> but i couldn't figure out where or if the server gets closed.
>
>  The Modbus socket gets closed in the library that implements the modbus
> stack...
>  
>  Details:
> ------------
>  Upon PLC shutdown, the LC code should call the Modbus plugin's __cleanup()
> function, which calls the modbus library's
> mb_slave_close()      (if running as server)
> or
> mb_master_close()   (if running as client)
>
>  As I said, these functions are implemented in the modbus library.
>  This library will eventually call the layer1
> modbus_close()
>
>  Which for modbus TCP is actually a pointer to function
> modbus_tcp_close()
>
>
>  This will eventually call
> close_connection()   (in mb_tcp.c file)
>  which will actually close the socket.
>
>
>    Let me know if you figure out what is happening and if anything needs to be
> fixed.
>
>
>
>   Cheers,
>
>         Mario.
>
>
> _______________________________________________
> Beremiz-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/beremiz-devel


_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Beremiz-devel] PLC crashes some times due to "Bind(): Address already in use" when using Modbus server node

Wisse Hooghiem
Hello,

Sorry for the late reaction, been a bit busy with some other stuff.
Edouard thank you for the reply this seems to fix the problem. I tested it the error didn't occur any more.

@mario let me know when it is pulled.

Met vriendelijke groet/ Kind regards, 

Wisse Hooghiem

Advanced Climate Systems bv | +31 (0)85 200 39 89 | P.O. Box 5241 |NL- 2000 CE  Haarlem| Wilhelminastraat 51 | NL-2011 VL | Haarlem



Op do 11 apr. 2019 om 14:05 schreef Edouard Tisserant <[hidden email]>:
Hello,

I fixed it already a few weeks ago, I forgot to publish :

https://hg.beremiz.org/Modbus/rev/1223f413e054

@Mario : please pull

Edouard


On 10/04/2019 16:48, Mario de Sousa via Beremiz-devel wrote:
>  Hi Wisse,
>
>

> On Wednesday, April 10, 2019 15:39:38 Wisse Hooghiem wrote:
>> Hi again,
>>
>> We have been using the beremiz editor, and runtime for over a year now
>> without any big problems. After updating to the latest source from
>> bitbucket a few weeks ago, sometimes the PLC crashes due to a "bind address
>> already in use error"
>> The situation is as follows, we have a Beremiz_runtime running inside a
>> docker container (ubuntu 16.04). This container is running on some server.
>> we recently updated the container with the latest source from bitbucket
>> (adding BACnet support to the systems) since this new container
>> sometimes the plc crashes and gives the following error:
>>
>> [image: Starting_error.png]
>>
>> I have a hard time figuring out when exactly the error occur's
>> sometimes it happens after:
>> - rebuild->stop->transfer->run
>> - or after stop->run
>> - or after stop->re transfer (without new build) -> run.
>>
>> anyhow it causes the plc to crash and the only way to fix it is to restart
>> the docker container
>> which in turn restarts the beremiz service.
>> the logs off the plc say that it has something to do with the Modbus server
>> node see image below:
>> [image: Beremiz_bind_error.png]
>>
>>
>> I discovered this problem when testing a project which has a BACnet and
>> Modbus server.
>> the only thing that happens is 2 numbers getting added on both protocol's
>>
>>
>> I think that sometimes the Modbus server doesn't close it's socket and then
>> on restarting the plc the runtime tries to start a new server when the
>> other one still exists somewhere. I looked in the code of the modbus runtime
>> but i couldn't figure out where or if the server gets closed.
>
>  The Modbus socket gets closed in the library that implements the modbus
> stack...

>  Details:
> ------------
>  Upon PLC shutdown, the LC code should call the Modbus plugin's __cleanup()
> function, which calls the modbus library's
> mb_slave_close()      (if running as server)
> or
> mb_master_close()   (if running as client)
>
>  As I said, these functions are implemented in the modbus library.
>  This library will eventually call the layer1
> modbus_close()
>
>  Which for modbus TCP is actually a pointer to function
> modbus_tcp_close()
>
>
>  This will eventually call
> close_connection()   (in mb_tcp.c file)
>  which will actually close the socket.
>
>
>    Let me know if you figure out what is happening and if anything needs to be
> fixed.
>
>
>
>   Cheers,
>
>         Mario.
>
>
> _______________________________________________
> Beremiz-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/beremiz-devel


_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel


_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel

image001.png (5K) Download Attachment