[OpenSIPS-Users] mediaproxy+twisted 10.0, doesn't use /etc/hosts when DNS requests timeouts
Nikita Kozlov
nikita at mbdsys.com
Mon Feb 27 12:45:18 CET 2012
Hello,
I think I have found a bug in media-relay if it's installed on a host
without any name resolver (empty /etc/resolv.conf, only /etc/hosts).
If mediaproxy is used with twitsted 10.X, the twisted defers' will fail
and we will enter in the _eb_no_srv callback but with a failure type of
TimeoutError.
Since TimeoutError isn't "traped" in _eb_no_srv we are not trying to
resolve it further because we are not executing reactor.resolve().
Feb 21 15:15:32 testnikiproxy2 media-relay[1086]: error: Unhandled error
in Deferred:
Feb 21 15:15:32 testnikiproxy2 media-relay[1086]: TimeoutError:
[Query('_sip._udp.testnikisip2', 33, 1)]
Note that I'm not sure if the error will happen with twisted 11.0+ since
the method setTimeout and TimeoutError were deprecated...
http://twistedmatrix.com/trac/browser/tags/releases/twisted-10.0.0/twisted/internet/defer.py#L399
http://twistedmatrix.com/trac/browser/tags/releases/twisted-11.0.0/twisted/internet/defer.py#L399
(setTimeout is not longer defined)
Anyway, here is a patch to fix it for twisted 10.0 :
diff -rN -u old-mediaproxy/mediaproxy/relay.py
new-mediaproxy/mediaproxy/relay.py
--- old-mediaproxy/mediaproxy/relay.py 2012-02-27 12:07:58.100162109 +0100
+++ new-mediaproxy/mediaproxy/relay.py 2012-02-27 12:07:58.123162912 +0100
@@ -16,7 +16,7 @@
from twisted.protocols.basic import LineOnlyReceiver
from twisted.internet.error import ConnectionDone, TCPTimedOutError,
DNSLookupError
from twisted.internet.protocol import ClientFactory
-from twisted.internet.defer import DeferredList, succeed
+from twisted.internet.defer import DeferredList, succeed, TimeoutError
from twisted.internet import reactor
from twisted.python import failure
from twisted.names import dns
@@ -260,7 +260,7 @@
raise DomainError
def _eb_no_srv(self, failure, addr, port):
- failure.trap(DomainError)
+ failure.trap(DomainError, TimeoutError)
return reactor.resolve(addr).addCallback(lambda host: (host,
port)).addErrback(self._eb_no_dns, addr)
def _eb_no_dns(self, failure, addr):
Regards,
--
Nikita
More information about the Users
mailing list