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

Failed to connect, retrying in 5.0s #334

Open
czar opened this issue Oct 7, 2020 · 9 comments
Open

Failed to connect, retrying in 5.0s #334

czar opened this issue Oct 7, 2020 · 9 comments

Comments

@czar
Copy link

czar commented Oct 7, 2020

Trying to run mkchromecast on Linux Mint 20, but this is what happens. I run, i open pavucontrol, and pipe the music to the mkchromecast sink, but no sound comes out... Here is what it says in the terminal.

$ mkchromecast
Mkchromecast v0.3.8.1
Creating Pulseaudio Sink...
Open Pavucontrol and Select the Mkchromecast Sink.
Starting Local Streaming Server
[Done]
Selected backend: parec
Selected audio codec: mp3
Default bitrate used: 192k
Default sample rate used: 44100Hz.
 * Serving Flask app "mkchromecast.audio" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
PID of main process: 50584
PID of streaming process: 50592
 
List of Devices Available in Network:
-------------------------------------

Index   Types   Friendly Name 
=====   =====   ============= 
0 	Gcast 	Living Room speaker
1 	Gcast 	Kitchen speaker
2 	Gcast 	all
 
Casting to first device shown above!
Select devices by using the -s flag.
 
Living Room speaker
 
[record[a,in-unique,a0b45b27-a863-8010-f953-b48393b9763a.local.]=120/119,192.168.1.11:8009] Failed to connect, retrying in 5.0s

*Edit: After searching and finding others w/ the same issue. I did this:
apt install python3-pip
then
pip3 install zeroconf==0.24.3

now it works.

@WhiteHusky
Copy link

Can affirm. I initially thought it was a firewall issue (this laptop has a strict set of ports) and opened them with no dice. After installing zeroconf==0.24.3 it was able to cast correctly.

@n6bhu
Copy link

n6bhu commented Nov 9, 2020

Outa sight man -- worked for me too -- THANX for the dope on this!

@Gunstick
Copy link

So what is the difference between zeroconf 0.24.3 (works) and 0.24.4 (does not work) and what would need to be changed to mkchromecast to work with the newest version?

@WhiteHusky
Copy link

So what is the difference between zeroconf 0.24.3 (works) and 0.24.4 (does not work) and what would need to be changed to mkchromecast to work with the newest version?

diff --git a/README.rst b/README.rst
index aae1124..432d3c4 100644
--- a/README.rst
+++ b/README.rst
@@ -134,6 +134,12 @@ See examples directory for more.
 Changelog
 =========
 
+0.24.4
+------
+
+* Fixed resetting TTL in DNSRecord.reset_ttl(), thanks to Matt Saxon
+* Improved various DNS class' string representations, thanks to Jay Hogg
+
 0.24.3
 ------
 
diff --git a/zeroconf/__init__.py b/zeroconf/__init__.py
index 6c9d55d..35fac80 100644
--- a/zeroconf/__init__.py
+++ b/zeroconf/__init__.py
@@ -42,7 +42,7 @@ import ifaddr
 
 __author__ = 'Paul Scott-Murphy, William McBrine'
 __maintainer__ = 'Jakub Stasiak <jakub@stasiak.at>'
-__version__ = '0.24.3'
+__version__ = '0.24.4'
 __license__ = 'LGPL'
 
 
@@ -420,7 +420,7 @@ class DNSEntry:
             result += ","
         result += self.name
         if other is not None:
-            result += ",%s]" % cast(Any, other)
+            result += "]=%s" % cast(Any, other)
         else:
             result += "]"
         return result
@@ -502,6 +502,8 @@ class DNSRecord(DNSEntry):
         another record."""
         self.created = other.created
         self.ttl = other.ttl
+        self._expiration_time = self.get_expiration_time(100)
+        self._stale_time = self.get_expiration_time(50)
 
     def write(self, out: 'DNSOutgoing') -> None:
         """Abstract method"""
@@ -509,7 +511,7 @@ class DNSRecord(DNSEntry):
 
     def to_string(self, other: Union[bytes, str]) -> str:
         """String representation with additional information"""
-        arg = "%s/%s,%s" % (self.ttl, self.get_remaining_ttl(current_time_millis()), cast(Any, other))
+        arg = "%s/%s,%s" % (self.ttl, int(self.get_remaining_ttl(current_time_millis())), cast(Any, other))
         return DNSEntry.entry_to_string(self, "record", arg)
 
 
@@ -538,9 +540,9 @@ class DNSAddress(DNSRecord):
     def __repr__(self) -> str:
         """String representation"""
         try:
-            return str(socket.inet_ntoa(self.address))
+            return self.to_string(str(socket.inet_ntoa(self.address)))
         except Exception:  # TODO stop catching all Exceptions
-            return str(self.address)
+            return self.to_string(str(self.address))
 
 
 class DNSHinfo(DNSRecord):
@@ -580,7 +582,7 @@ class DNSHinfo(DNSRecord):
 
     def __repr__(self) -> str:
         """String representation"""
-        return self.cpu + " " + self.os
+        return self.to_string(self.cpu + " " + self.os)
 
 
 class DNSPointer(DNSRecord):
diff --git a/zeroconf/test.py b/zeroconf/test.py
index f0d5ad4..5a89c9f 100644
--- a/zeroconf/test.py
+++ b/zeroconf/test.py
@@ -79,6 +79,21 @@ class TestDunder(unittest.TestCase):
         self.assertRaises(r.AbstractMethodException, record.__eq__, record)
         self.assertRaises(r.AbstractMethodException, record.write, None)
 
+    def test_dns_record_reset_ttl(self):
+        record = r.DNSRecord('irrelevant', r._TYPE_SRV, r._CLASS_IN, r._DNS_HOST_TTL)
+        time.sleep(1)
+        record2 = r.DNSRecord('irrelevant', r._TYPE_SRV, r._CLASS_IN, r._DNS_HOST_TTL)
+        now = r.current_time_millis()
+
+        assert record.created != record2.created
+        assert record.get_remaining_ttl(now) != record2.get_remaining_ttl(now)
+
+        record.reset_ttl(record2)
+
+        assert record.ttl == record2.ttl
+        assert record.created == record2.created
+        assert record.get_remaining_ttl(now) == record2.get_remaining_ttl(now)
+
     def test_service_info_dunder(self):
         type_ = "_test-srvc-type._tcp.local."
         name = "xxxyyy"

@perj
Copy link

perj commented Sep 13, 2021

Affects Ubuntu 20.04 mkchromecast installed via apt, it seems.

@j2l
Copy link

j2l commented Sep 25, 2021

Affects Ubuntu 20.04 mkchromecast installed via apt, it seems.

Yes, I arrived here because of this error on ubuntu 20.04.
Unfortunately, downgrading zeroconf didn't do the trick for me.
I can cast using vlc or chromium but not mkchromecast and I'd like to cast the desktop screen, not just video.

@dawonn
Copy link

dawonn commented Sep 26, 2021

FWIW, this fix worked for me. I had 0.24.4 installed by default on Ubuntu 20.04; rolling back to 0.24.3 and it's working perfectly. :)

@shawndooley
Copy link

@WhiteHusky

-            result += ",%s]" % cast(Any, other)
+            result += "]=%s" % cast(Any, other)

I think this is the change in that diff that caused the issue. I haven't taken the time yet to figure out exactly what this does, but if I change only that line in my local zeroconf/__init__.py I am able to cast without issue.

@martinzoller
Copy link

@WhiteHusky

-            result += ",%s]" % cast(Any, other)
+            result += "]=%s" % cast(Any, other)

I think this is the change in that diff that caused the issue. I haven't taken the time yet to figure out exactly what this does, but if I change only that line in my local zeroconf/__init__.py I am able to cast without issue.

This also did the trick for me on Ubuntu 20.04.3.

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

No branches or pull requests

9 participants