ni / niflexlogger-automation-python

The niflexlogger-automation package contains an API (Application Programming Interface) and examples for using Python to automate NI FlexLogger. The automation API supports modifying the configuration of existing FlexLogger projects and controlling the execution of FlexLogger test sessions. The package is implemented in Python. NI created and supports this package.
MIT License
8 stars 6 forks source link

Error when trying example to open active project with flexlogger 2021 R1 #13

Closed tcase closed 3 years ago

tcase commented 3 years ago

Running the code below I get the following error - flexlogger version 2021 R1 Build number 8.4.0.49979:

from flexlogger.automation import Application
app = Application()
project = app.get_active_project()
Traceback (most recent call last):
  File "C:\Python36\lib\site-packages\flexlogger\automation\_application.py", line 223, in get_active_project
    response = stub.GetActiveProject(FlexLoggerApplication_pb2.GetActiveProjectRequest())
  File "C:\Python36\lib\site-packages\grpc\_channel.py", line 923, in __call__
    return _end_unary_response_blocking(state, call, False, None)
  File "C:\Python36\lib\site-packages\grpc\_channel.py", line 826, in _end_unary_response_blocking
    raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
        status = StatusCode.UNAVAILABLE
        details = "failed to connect to all addresses"
        debug_error_string = "{"created":"@1608052709.612000000","description":"Failed to pick subchannel","file":"src/core/ext/filters/client_channel/client_channel.cc","file_line":4143,"referenced_errors":[{"created":"@1608052633.077000000","description":"failed to connect to all addresses","file":"src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc","file_line":398,"grpc_status":14}]}"
>

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python36\lib\site-packages\flexlogger\automation\_application.py", line 236, in get_active_project
    raise FlexLoggerError("Failed to get the active project") from rpc_error
flexlogger.automation._flexlogger_error.FlexLoggerError: <exception str() failed>

"C:\ProgramData\National Instruments\FlexLogger\LastAutomationPort.txt" contains: 49793

gregstoll commented 3 years ago

Hi Travis -

Hmm, that's interesting. Can you confirm that the preference under the General tab for "Enable FlexLogger to receive remote automation commands" is on? And was there a project open in FlexLogger when you called get_active_project()?

Thanks!

Greg Stoll FlexLogger R&D

tcase commented 3 years ago

Yes I can confirm both of those conditions are true

image

gregstoll commented 3 years ago

Hmm, OK. Do you see the same behavior if you try to call Application.launch() and then get_active_project()? And what about if you call open_project() instead of get_active_project()?

Thanks!

Greg Stoll FlexLogger R&D

gregstoll commented 3 years ago

I tried this internally and it works, so I'm guessing something about our machine setups is different.

One possibility is that your machine is using a proxy; can you try putting the following code before the call to Application()?

if os.environ.get('https_proxy'):
    del os.environ['https_proxy']
if os.environ.get('http_proxy'):
    del os.environ['http_proxy']

Another possibility is that the client is trying to connect over IPv6 instead of IPv4. We can try changing line 119 in _application.py from

            self._channel = insecure_channel("localhost:%d" % self._server_port)

to

            self._channel = insecure_channel("127.0.0.1:%d" % self._server_port)

Let me know if you're able to try these!

Greg Stoll FlexLogger R&D

tcase commented 3 years ago

We are using a proxy on our hosts and it looks like removing that is fixing the problem. not sure why thats happening as the proxy should not be messing with localhost connections.

tcase commented 3 years ago

ok i think I figured out the proxy issue, I need to change our env var from:

os.environ['no_proxy'] = 'intel.com,127.0.0.1' to os.environ['no_proxy'] = 'intel.com,127.0.0.1,localhost'

thanks for your help @gregstoll !

tcase commented 3 years ago

@gregstoll can we get a note added to the documentation to say that ni is using http traffic and honors proxy env vars related to that?

gregstoll commented 3 years ago

Yes, that's a good idea. I also wonder if we should be using 127.0.0.1 instead of localhost in our code, which I'm guessing would have avoided this issue.