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 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 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

  • Tue, 06/09/2026 - 11:16
    gurux.dlms.java 4.0.95
  • Tue, 06/09/2026 - 10:03
    Gurux.DLMS.Python 1.0.199
  • Mon, 06/08/2026 - 13:39
    gurux.dlms.cpp 9.0.2606.0801
  • Mon, 06/01/2026 - 10:15
    gurux.dlms.cpp 9.0.2606.0101
  • Thu, 05/28/2026 - 16:06
    gurux.dlms.java 4.0.94

New forum topics

  • Error reading L&G Meter
  • Pass a TCP Client to GXNet
  • Australian EDMI Mk10D (Essential Energy area)
  • Strange mix of data notificiation vs get response
  • DLMS Connection
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin