AnsweredAssumed Answered

PI Web API throwing Error

Question asked by ROCSBE on Aug 5, 2020

Hi,

 

I have a team that is developing some code based on PI Web API and is using the GitHub repositories for help. Recently, they have developed a full code and it is sometimes working on their machine. When they tried to deploy this code on a production server, it is throwing below error-

 

During handling of the above exception, another exception occurred:

 

Traceback (most recent call last):

  File "/run/media/root/Storage/SBEnergy/AA_RJ200_R5/src/com/sbenergy/utils/Helper.py", line 30, in getListOfWebIds

    web_id = client.point.get_by_path(tags[key]).web_id;

  File "/run/media/root/Storage/SBEnergy/AA_RJ200_R5/osisoft/pidevclub/piwebapi/api/point_api.py", line 29, in get_by_path

    (data) = self.get_by_path_with_http_info(path, selected_fields, web_id_type, **kwargs)

  File "/run/media/root/Storage/SBEnergy/AA_RJ200_R5/osisoft/pidevclub/piwebapi/api/point_api.py", line 93, in get_by_path_with_http_info

    collection_formats =collection_formats)

  File "/run/media/root/Storage/SBEnergy/AA_RJ200_R5/osisoft/pidevclub/piwebapi/api_client.py", line 312, in call_api

    _return_http_data_only, collection_formats, _preload_content, _request_timeout)

  File "/run/media/root/Storage/SBEnergy/AA_RJ200_R5/osisoft/pidevclub/piwebapi/api_client.py", line 140, in __call_api

    body=body)

  File "/run/media/root/Storage/SBEnergy/AA_RJ200_R5/osisoft/pidevclub/piwebapi/api_client.py", line 330, in request

    headers=headers)

  File "/run/media/root/Storage/SBEnergy/AA_RJ200_R5/osisoft/pidevclub/piwebapi/rest.py", line 57, in send_request

    response = requests.get(url, auth=self.auth, headers=headers, verify=self.verifySsl)

  File "/root/anaconda3/envs/sbenergy/lib/python3.7/site-packages/requests/api.py", line 76, in get

    return request('get', url, params=params, **kwargs)

  File "/root/anaconda3/envs/sbenergy/lib/python3.7/site-packages/requests/api.py", line 61, in request

    return session.request(method=method, url=url, **kwargs)

  File "/root/anaconda3/envs/sbenergy/lib/python3.7/site-packages/requests/sessions.py", line 530, in request

    resp = self.send(prep, **send_kwargs)

  File "/root/anaconda3/envs/sbenergy/lib/python3.7/site-packages/requests/sessions.py", line 643, in send

    r = adapter.send(request, **kwargs)

  File "/root/anaconda3/envs/sbenergy/lib/python3.7/site-packages/requests/adapters.py", line 516, in send

    raise ConnectionError(e, request=request)

requests.exceptions.ConnectionError: HTTPSConnectionPool(host='azvm-pivision.sbenergy.com', port=443): Max retries exceeded with url: /piwebapi/points?path=%5C%5CAZVM-PISRV%5CINS_RJ_003_R05_SC_MCR_WMS_DIR+IRR.PV (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f0078d13490>: Failed to establish a new connection: [Errno -2] Name or service not known'))

 

During handling of the above exception, another exception occurred:

 

Traceback (most recent call last):

  File "/root/anaconda3/envs/sbenergy/lib/python3.7/logging/__init__.py", line 1025, in emit

    msg = self.format(record)

  File "/root/anaconda3/envs/sbenergy/lib/python3.7/logging/__init__.py", line 869, in format

    return fmt.format(record)

  File "/root/anaconda3/envs/sbenergy/lib/python3.7/logging/__init__.py", line 608, in format

    record.message = record.getMessage()

  File "/root/anaconda3/envs/sbenergy/lib/python3.7/logging/__init__.py", line 369, in getMessage

    msg = msg % self.args

TypeError: not all arguments converted during string formatting

Call stack:

  File "main.py", line 34, in <module>

    main()

  File "main.py", line 27, in main

    startServer()

  File "/run/media/root/Storage/SBEnergy/AA_RJ200_R5/src/com/sbenergy/StartAAPlatform.py", line 66, in startServer

    http_server = tornado.httpserver.HTTPServer(Application())

  File "/run/media/root/Storage/SBEnergy/AA_RJ200_R5/src/com/sbenergy/StartAAPlatform.py", line 19, in __init__

    Helper.getListOfWebIds()

  File "/run/media/root/Storage/SBEnergy/AA_RJ200_R5/src/com/sbenergy/utils/Helper.py", line 39, in getListOfWebIds

    log.error("Exception inside getListOfWebIds", exc)

Message: 'Exception inside getListOfWebIds'

Arguments: (ConnectionError(MaxRetryError("HTTPSConnectionPool(host='azvm-pivision.sbenergy.com', port=443): Max retries exceeded with url: /piwebapi/points?path=%5C%5CAZVM-PISRV%5CINS_RJ_003_R05_SC_MCR_WMS_DIR+IRR.PV (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f0078d13490>: Failed to establish a new connection: [Errno -2] Name or service not known'))")),)

2020-08-04 13:35:21,846 ERROR __main__     'module' object is not callable

I talked to them about the code, in which they said, they are trying to get WEBIDs of PI Points from the Web API before making Streamset call for getting current data.

PI Server is an Azure based VM and the machine where my team is trying to deploy the code is also an Azure VM. I am not sure whether this is an issue related to Network or it is a PI Performance issue.

 

Can anyone help me out here?

 

Thanks,

Anshul

Outcomes