Fix an issue when PIO Remote agent was not reconnected automatically

This commit is contained in:
Ivan Kravets
2020-04-21 12:32:03 +03:00
parent c4645a9a96
commit 2960b73da5
2 changed files with 18 additions and 7 deletions

View File

@ -35,4 +35,4 @@ __copyright__ = "Copyright 2014-present PlatformIO"
__apiurl__ = "https://api.platformio.org"
__pioaccount_api__ = "https://api.accounts.platformio.org"
__pioremote_endpoint__ = "ssl:remote.platformio.org:4413"
__pioremote_endpoint__ = "ssl:host=remote.platformio.org:port=4413"

View File

@ -73,15 +73,26 @@ class RemoteClientBase( # pylint: disable=too-many-instance-attributes
def connect(self):
self.log.info("Name: {name}", name=self.name)
self.log.info("Connecting to PIO Remote Cloud")
endpoint = endpoints.clientFromString(reactor, __pioremote_endpoint__)
# pylint: disable=protected-access
proto, options = endpoints._parse(__pioremote_endpoint__)
proto = proto[0]
factory = RemoteClientFactory()
factory.remote_client = self
factory.sslContextFactory = None
if __pioremote_endpoint__.startswith("ssl:"):
# pylint: disable=protected-access
factory.sslContextFactory = SSLContextFactory(endpoint._host)
endpoint._sslContextFactory = factory.sslContextFactory
endpoint.connect(factory)
if proto == "ssl":
factory.sslContextFactory = SSLContextFactory(options["host"])
reactor.connectSSL(
options["host"],
int(options["port"]),
factory,
factory.sslContextFactory,
)
elif proto == "tcp":
reactor.connectTCP(options["host"], int(options["port"]), factory)
else:
raise exception.PlatformioException("Unknown PIO Remote Cloud protocol")
reactor.run()
if self._exit_code != 0: