FreeTAKTeam / FreeTakServer

Situational Awareness Server compatible with TAK clients
Eclipse Public License 2.0
649 stars 166 forks source link

change WebGUI code to catch exceptions related to connection issues #509

Closed lomfs24 closed 5 months ago

lomfs24 commented 1 year ago

I have a brand new install of Ubuntu 20.04 Server. Then a brand new install of FreeTAKServer via the zerotouch command on 1/8/2023. It appears that FreeTAKServer is up and running as I can connect to it locally with a couple of different ATAK devices by using an unsecured TCP connection. However, when I go to the web-UI it pops right up. I enter the default credentials, as it's a brand new install. And it will sit there for a long... long.... long time. And will eventually display this instead of the correct page. It appears to be a problem with python, but I have no idea how to troubleshoot or fix.

Traceback (most recent call last): File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 159, in _new_conn conn = connection.create_connection( File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 84, in create_connection raise err File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 74, in create_connection sock.connect(sa) TimeoutError: [Errno 110] Connection timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 665, in urlopen httplib_response = self._make_request( File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 387, in _make_request conn.request(method, url, **httplib_request_kw) File "/usr/lib/python3.8/http/client.py", line 1256, in request self._send_request(method, url, body, headers, encode_chunked) File "/usr/lib/python3.8/http/client.py", line 1302, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/usr/lib/python3.8/http/client.py", line 1251, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/usr/lib/python3.8/http/client.py", line 1011, in _send_output self.send(msg) File "/usr/lib/python3.8/http/client.py", line 951, in send self.connect() File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 187, in connect conn = self._new_conn() File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 171, in _new_conn raise NewConnectionError( urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f79c1db0370>: Failed to establish a new connection: [Errno 110] Connection timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/lib/python3/dist-packages/requests/adapters.py", line 439, in send resp = conn.urlopen( File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 719, in urlopen retries = retries.increment( File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 436, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='76.75.33.36', port=19023): Max retries exceeded with url: /AuthenticateUser?username=admin&password=password (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f79c1db0370>: Failed to establish a new connection: [Errno 110] Connection timed out'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/eventlet/wsgi.py", line 573, in handle_one_response result = self.application(self.environ, start_response) File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 2464, in call return self.wsgi_app(environ, start_response) File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 2450, in wsgi_app response = self.handle_exception(e) File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1867, in handle_exception reraise(exc_type, exc_value, tb) File "/usr/local/lib/python3.8/dist-packages/flask/_compat.py", line 39, in reraise raise value File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 2447, in wsgi_app response = self.full_dispatch_request() File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1952, in full_dispatch_request rv = self.handle_user_exception(e) File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1821, in handle_user_exception reraise(exc_type, exc_value, tb) File "/usr/local/lib/python3.8/dist-packages/flask/_compat.py", line 39, in reraise raise value File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1950, in full_dispatch_request rv = self.dispatch_request() File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1936, in dispatch_request return self.view_functionsrule.endpoint File "/usr/local/lib/python3.8/dist-packages/FreeTAKServer-UI/app/base/routes.py", line 42, in login user = requests.get(f"http://{app.config['IP']}:{app.config['PORT']}/AuthenticateUser", params={"username": username, "password": password}, headers={"Authorization": f"{app.config['APIKEY']}"}) File "/usr/lib/python3/dist-packages/requests/api.py", line 75, in get return request('get', url, params=params, kwargs) File "/usr/lib/python3/dist-packages/requests/api.py", line 60, in request return session.request(method=method, url=url, kwargs) File "/usr/lib/python3/dist-packages/requests/sessions.py", line 533, in request resp = self.send(prep, send_kwargs) File "/usr/lib/python3/dist-packages/requests/sessions.py", line 646, in send r = adapter.send(request, kwargs) File "/usr/lib/python3/dist-packages/requests/adapters.py", line 516, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPConnectionPool(host='76.75.33.36', port=19023): Max retries exceeded with url: /AuthenticateUser?username=admin&password=password (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f79c1db0370>: Failed to establish a new connection: [Errno 110] Connection timed out'))

brothercorvo commented 1 year ago

it seems the UI cannot find your FTS core IP, try to change the IP to reflect your netweork configuration

Kysodaat commented 1 year ago

I had the same problem, I'm using zerotier and changed the IP address to the zerotier IP in the config.py file and now I can login into the web UI, for some reason the IP address was defaulted to my home router when I did the install, thanks corvo this has been bugging me for a month now. I am slowly learning how to config everything and find the right files.

SCWhite commented 1 year ago

@Kysodaat HI have you checked your FTS server? you need both FTS server & FTS-ui running. the document may be a bit confusing with those word.

habr05 commented 1 year ago

try following settings:

in FTSConfig.yaml set all 3 ports to 0.0.0.0 in config.py set IP to external IP, APPIP to 0.0.0.0, and WEBMAP to external IP

brothercorvo commented 1 year ago

image

@durinwinter to avoid the error message we should catch an exception an returns an error in the UI

durinwinter commented 1 year ago

Okay we will look at adding some error handling on that.