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

SHOT-4398: Fix proxy server handling #208

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion docs/changes.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
What's New
####################################################

The latest version of the Alias Engine is ``v4.1.2``.
The latest version of the Alias Engine is ``v4.1.4``.

.. include:: v4.1.4.rst

.. include:: v4.1.3.rst

.. include:: v4.1.2.rst

Expand Down
37 changes: 37 additions & 0 deletions docs/environment_vars.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Environment Variables
####################################################

Listed below are environment variables used by the Alias Engine.

TK_ALIAS_OPEN_MODEL
-----------------------------

* Set to ``1`` to run the Alias Engine in headless mode without Alias GUI.

TK_ALIAS_HAS_UI
-----------------------------

* Set to ``1`` to run Alias Engine in headless mode without Flow Production Tracking UI.

ALIAS_PLUGIN_CLIENT_ALIAS_VERSION
----------------------------------

* Set to the Alias version number
* This is used when running the Alias Engine in headless mode

ALIAS_PLUGIN_CLIENT_ALIAS_EXECPATH
-----------------------------------

* Set to the directory containing the Alias executable (e.g. Alias.exe)
* This is used when running the Alias Engine in headless mode

.. _env_var_sgtk_enforce_proxy_localhost:

SGTK_ENFORCE_PROXY_LOCALHOST
-----------------------------

* Set to ``1`` to use environment variables for proxy settings.
* Do not set to ignore environment variables for proxy settings.
* Default is not set to ignore environment variables for proxy settings.


Binary file added docs/images/alias-prompt-comm-failed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ Contents
.. toctree::
:maxdepth: 2

changes
engine
hooks
api
changes
environment_vars
troubleshooting
104 changes: 104 additions & 0 deletions docs/troubleshooting.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
Troubleshooting
~~~~~~~~~~~~~~~~

Alias does not launch from FPT Desktop
=============================================

1. Check the FPT Desktop Engine log for error messages. The log file should be found at ``%APPDATA%\Shotgun\Logs\tk-desktop.log``

2. Check that this folder exists ``%APPDATA%\Autodesk\Alias\ShotGrid``.


Flow Production Menu does not appear in Alias
=============================================

In this case, Alias has launched successfully from FPT Desktop but the Flow Production Menu does not appear.

1. Check the Alias Promptline History for error messages. If successful, you will see the following messages:

.. code-block:: console

Embedded Python Interpreter: C:\Users\qa\AppData\Roaming\Autodesk\Alias\ShotGrid\Python\Python37\install\python.exe
Python Version: 3.7.11 (default, Dec 18 2022, 00:12:45) [MSC v.1900 64 bit (AMD64)]
Python Path: C:\Users\qa\AppData\Roaming\Autodesk\Alias\ShotGrid\Python\Python37\install\python37.zip;C:\Users\qa\AppData\Roaming\Autodesk\Alias\ShotGrid\Python\Python37\install;<path_to_tk-framework-alias>\python
Running Alias Python API server
Starting client 'flow-production-tracking'...
Flow Production Tracking initialized

2. Check the FPT Alias Engine log for error messages. The log file should be found at ``%APPDATA%\Shotgun\Logs\tk-alias.log``. If there is no tk-alias.log file, that means the FPT Alias Plugin may have loaded, but it then failed to start the FPT Alias Engine.

3. Check the FPT Alias plugin logs for error message. These logs are found in the folder ``%APPDATA%\Autodesk\Alias\ShotGrid\plugin\logs``. There are three logs:
* wsgi.log
* sio_server.log
* sio_client.log

If the FPT Alias communication has started up successfully, you should see in the ``wsgi.log``:

.. code-block:: console

(9328) wsgi starting up on http://127.0.0.1:8000
(9328) accepted ('127.0.0.1', 63313)
127.0.0.1 - - [11/Dec/2024 09:26:47] "GET /socket.io/?transport=polling&EIO=4&t=1733927207.5092578 HTTP/1.1" 200 279 0.000000

* Line 1: This indicates the WSGI web server has started up and listening on host 127.0.0.1 on port 8000. The ID of the process running the server is 9328.
* Line 2: The server has received and accepted a new client connection. The client sent the connection from PID 63313.
* Line 3: The client made a GET request to the server, and the server reported a successful 200 response.

If only Line 1 is logged, then the server has started but has not received any connections. Check that your firewall settings allow incoming connections and traffic to the host and port number.

4. Test if a simple HTTP client can connect to the server:

a. Launch Alias

b. Check the AppData/Roaming/Autodesk/Alias/ShotGrid/plugin/logs/wsgi.log file to see this gets logs:

.. code-block:: console

(3692) wsgi starting up on http://127.0.0.1:8000/

c. Then open a python interpreter and run:

.. code-block:: python

# May need to run python -m pip install requests
import requests

# Manually send a request to check if the server is running and can receive a new connection
response = requests.get("http://127.0.0.1:8000/socket.io/?transport=polling&EIO=4")
print(response)

# Should see output <Response [200]> if server is started successfully and receiving connections

Note that if the port is different, you will need to replace ``8000`` with the port that is in the log message

Proxy Server Troubleshooting
------------------------------

If you are running Flow Production Tracking with a proxy server, you may encounter issues with Alias. To troubleshoot:

1. Turn on "Advanced > Toggle Debug Logging" from Flow Production Tracking Desktop

2. Launch Alias from Flow Production Tracking Desktop

3. If you do not see a Python console window pop up after launching Alias, your proxy server may be causing Flow Production Tracking to fail.

4. Check the Alias prompt line for error messages, if you see this error, your proxy server may be causing Flow Production Tracking to fail.

.. image:: images/alias-prompt-comm-failed.png
:alt: Publish Export Selection
:width: 800px
:align: center

\

**Possible solution:**

Before launching Flow Production Tracking Desktop, set the environment variable :ref:`env_var_sgtk_enforce_proxy_localhost` to ``1``. This will force Flow Production Tracking Desktop to use the proxy settings from the environment variables:

.. code-block:: console

set SGTK_ENFORCE_PROXY_LOCALHOST=1
"C:\Program Files\Shotgun\Shotgun.exe"


**If you are experiencing any of these issues, please contact support.**
3 changes: 0 additions & 3 deletions docs/v4.0.1.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
v4.0.1
=====================

Release highlights
------------------

* Fix Alias Engine restart after Alias application exits unexpectedly
3 changes: 0 additions & 3 deletions docs/v4.1.2.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
v4.1.2
=====================

Release highlights
------------------

* Improve error handling on Alias start up
* Improve Alias API timeout handling

5 changes: 5 additions & 0 deletions docs/v4.1.3.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
v4.1.3
=====================

* Bug fix for running Background Publishing in Alias

9 changes: 9 additions & 0 deletions docs/v4.1.4.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
v4.1.4
=====================

* Bug fix to load Flow Production Tracking with Alias >= 2024.0 when using a proxy server

* Added environment variable :ref:`env_var_sgtk_enforce_proxy_localhost` to use or ignore environment variables for proxy settings.

* Bug fix for showing Alias icon in Flow Production Tracking Desktop

16 changes: 15 additions & 1 deletion engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@


import os
import requests
import sys
import pprint

Expand Down Expand Up @@ -914,9 +915,22 @@ def __setup_sio(self, hostname, port, namespace):
:rtype: bool
"""

# Set up kwargs to pass to socketio Client
client_kwargs = {"timeout": 60 * 3}
if os.environ.get("SGTK_ENFORCE_PROXY_LOCALHOST", "0").strip().lower() not in [
"1",
"true",
"y",
"yes",
]:
# Set up a session object to disable proxy
session = requests.Session()
session.trust_env = False
client_kwargs["http_session"] = session

# Create and connect to the server to communicate with Alias
self.__sio = self._tk_alias.ShotGridAliasSocketIoClient(
self, namespace, timeout=60 * 3
self, namespace, **client_kwargs
)

if not self.__sio:
Expand Down
5 changes: 5 additions & 0 deletions startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,10 @@ def __ensure_plugin_ready(self, framework_location, alias_version, alias_exec_pa
entity_dict = self.context.task or self.context.entity or self.context.project
entity_type = entity_dict["type"]
entity_id = entity_dict["id"]
# Check if we should trust env vars for proxy settings or ignore
proxy_trust_env = os.environ.get(
"SGTK_ENFORCE_PROXY_LOCALHOST", "0"
).strip().lower() in ["1", "true", "y", "yes"]

# Ensure the basic.alias plugin is installed and up to date
return startup_utils.ensure_plugin_ready(
Expand All @@ -422,6 +426,7 @@ def __ensure_plugin_ready(self, framework_location, alias_version, alias_exec_pa
pipeline_config_id,
entity_type,
entity_id,
proxy_trust_env,
os.environ.get("TK_DEBUG", "0"),
self.logger,
)