Skip to content

Commit

Permalink
try 2ndary port when connecting to feed.adsbexchange.com
Browse files Browse the repository at this point in the history
  • Loading branch information
wiedehopf committed Oct 11, 2020
1 parent ae5fd32 commit fb99090
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion mlat-client
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ location pin from the coverage maps.""",
server.add_argument('--server',
help="host:port of the multilateration server to connect to",
type=options.hostport,
default=('mlat.mutability.co.uk', 40147))
default=('feed.adsbexchange.com', 31090))
server.add_argument('--no-udp',
dest='udp',
help="Don't offer to use UDP transport for sync/mlat messages",
Expand Down
2 changes: 1 addition & 1 deletion mlat/client/jsonclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def __str__(self):


class JsonServerConnection(mlat.client.net.ReconnectingConnection):
reconnect_interval = 30.0
reconnect_interval = 15.0
heartbeat_interval = 120.0
inactivity_timeout = 60.0

Expand Down
17 changes: 15 additions & 2 deletions mlat/client/net.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ class ReconnectingConnection(LoggingMixin, asyncore.dispatcher):
host/port, reconnecting on connection loss.
"""

reconnect_interval = 30.0

def __init__(self, host, port):
asyncore.dispatcher.__init__(self)
self.host = host
self.basePort = port
self.port = port
self.adsbexchangePorts = [ 31090, 64590 ]
if self.host == 'feed.adsbexchange.com' and self.basePort == 31090:
self.port = 64590
self.addrlist = []
self.state = 'disconnected'
self.reconnect_at = None
Expand Down Expand Up @@ -119,6 +121,17 @@ def reconnect(self):

if len(self.addrlist) == 0:
# ran out of addresses to try, resolve it again
if self.host == 'feed.adsbexchange.com' and self.basePort == 31090:
for index, port in enumerate(self.adsbexchangePorts):
if self.port == port:
self.port = self.adsbexchangePorts[(index + 1) % len(self.adsbexchangePorts)]
break

if self.host == 'feed.adsbexchange.com' and self.basePort != self.port:
log('Connecting to {host}:{port} (trying hard-coded alternate port for adsbexchange)', host=self.host, port=self.port)
else:
log('Connecting to {host}:{port}', host=self.host, port=self.port)

self.addrlist = socket.getaddrinfo(host=self.host,
port=self.port,
family=socket.AF_UNSPEC,
Expand Down
2 changes: 1 addition & 1 deletion mlat/client/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@

"""Just a version constant!"""

CLIENT_VERSION = "0.3.0"
CLIENT_VERSION = "0.3.1"

0 comments on commit fb99090

Please sign in to comment.