Skip to main content
Home
for DLMS smart meters
Open source solutions for DLMS smart metering

Main navigation

  • Home
  • Products
  • About us
  • Open Source
  • Community
  • Forum
  • Downloads
User account menu
  • Log in

Breadcrumb

  1. Home
  2. IPv6 UDP Socket Spawns Streams

IPv6 UDP socket spawns streams

By alexcd , 23 May, 2024
Forums
Gurux.Net

Hello, I have a problem with the IPv6 UDP connection in Python. I discovered that there is a resource leak if the library was unable to establish a connection.
I poll my counters in a loop, if the connection to the counter fails I get an error
"Failed to receive reply from the device in given time". My code moves on to the next iteration and I see that a new thread is being spawned, and so on every time.

active_threads = threading.enumerate()

for thread in active_threads:
print("Thread ID:", thread.ident)
print("Thread Name:", thread.name)

Thread Name: Thread-4 (__listenerThread)
Thread ID: 2958029856
Thread Name: Thread-6 (__listenerThread)
Thread ID: 2949637152
Thread Name: Thread-8 (__listenerThread)
Thread ID: 2941244448
Thread Name: Thread-10 (__listenerThread)
Thread ID: 2932589600
Thread Name: Thread-12 (__listenerThread)
Thread ID: 2923410464
Thread Name: Thread-14 (__listenerThread)
Thread ID: 2914755616
Thread Name: Thread-16 (__listenerThread)
Thread ID: 2906100768
Thread Name: Thread-18 (__listenerThread)
Thread ID: 2897183776
Thread Name: Thread-20 (__listenerThread)
Thread ID: 2888791072
Thread Name: Thread-22 (__listenerThread)
Thread ID: 2880398368
Thread Name: Thread-24 (__listenerThread)
Thread ID: 2872005664
Thread Name: Thread-26 (__listenerThread)
Thread ID: 2863612960
Thread Name: Thread-28 (__listenerThread)
Thread ID: 2855220256
Thread Name: Thread-30 (__listenerThread)
Thread ID: 2846827552
Thread Name: Thread-32 (__listenerThread)
Thread ID: 2838434848
Thread Name: Thread-34 (__listenerThread)
Thread ID: 2830042144
Thread Name: Thread-36 (__listenerThread)

alexcd

2 years 2 months ago

I solved my problem, you can…

I solved my problem, you can add self.media.close() before the error in readDLMSPacket2 method. If it is an IP connection.

Profile picture for user Kurumi

Kurumi

2 years 2 months ago

Hi, Don't add media close to…

Hi,

Don't add media close to the readDLMSPacket2. It's common that the meter might return an error, e.g. if you try to write a value that is read-only. Now the connection hangs and some meters don't respond until inactivity timeout has passed.

The correct way to close the media is after you have closed the connection and call disconnectRequest.

BR,
Mikko

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Mon, 07/27/2026 - 12:37
    gurux.dlms.cpp 9.0.2607.2701
  • Thu, 07/23/2026 - 16:19
    gurux.dlms.java 4.0.96
  • Thu, 07/09/2026 - 14:34
    Gurux.DLMS.Python 1.0.201
  • Fri, 06/26/2026 - 16:32
    Gurux.Service 3.0.2606.2601
  • Wed, 06/24/2026 - 08:36
    Gurux.DLMS.Python 1.0.200

New forum topics

  • Service not known error on gprs communication
  • Help Needed: Interfacing Saral 100 Energy Meter with Microcontroller via RS232
  • Connecting Meter to Agent via serial
  • Reading block profile with Compact array
  • DLMS server - serving multiple similar datasets gathered from multiple meters across distinct logical addresses
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin