dlubal-software / RFEM_Python_Client

Python client (or high-level functions) for RFEM 6 using Web Services, SOAP and WSDL
https://dlubal-software.github.io/.github/
MIT License
71 stars 27 forks source link

BUG: Failure to connect to server #375

Open bjoernsteinhagen opened 5 months ago

bjoernsteinhagen commented 5 months ago

Describe the bug The connectToServerfunction within initModel.py fails with the following message in terminal:

  File "c:\Users\bsteinhagen\Documents\GitHub\tcc-toolbox\tcc_toolbox\analysis\rfem.py", line 30, in __init__
    Model(True, model_name, True, True)
  File "C:\Users\bsteinhagen\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\RFEM\initModel.py", line 123, in __init__
    connectToServer()
  File "C:\Users\bsteinhagen\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\RFEM\initModel.py", line 49, in connectToServer
    new_wsdl = request.urlopen(urlAndPort+'/wsdl')
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 525, in open
    response = meth(req, response)
               ^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 634, in http_response
    response = self.parent.error(
               ^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 563, in error
    return self._call_chain(*args)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 496, in _call_chain
    result = func(*args)
             ^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 643, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found

Desktop (please complete the following information):

Additional context Working on other machines just not mine. RFEM6 has been uninstalled and reinstalled, Python Client has been uninstalled and reinstalled. Older version of Python client yielded following error:

Connecting to server...
Error: Connection to server failed!
Please check:
- If you have started RFEM application
- If all RFEM dialogs are closed
- If server port range is set correctly
- If you have a valid Web Services license
- Check Program Options & Settings > Web Services
On remote PC please check:
- If the firewall enables you to listen to selected port.
OndraMichal commented 4 months ago

Hi @bjoernsteinhagen, from the description I can only deduct that URL or port is not correct. But it is odd that it works on other computers. Seems to be a local issue.

JohannesSchorr commented 2 months ago

Hey, I am having similar issues.

Desktop

Windows: Windows 11 Pro (Version: 23H2) RFEM: 6.05.0003 Python-Client: 1.19.5

Further Digging

I run the following code on port 8081.

from suds.client import Client
client = Client("http://localhost:8081/wsdl")
print(client.service.get_active_model())

It gave me http://127.0.0.1:8082/. Passing this or http://localhost:8082/wsdl as argument to Client in the code above, leads to: suds.MethodNotFound: Method not found: 'RfemModel.RfemModelPort.get_active_model'

Passing http://localhost:8081/wsdl and http://localhost:8082/wsdl to my browser shows a XML-file.

Questions / Ideas I had to solve the problem

Possible Solution / Quick Fix

Closing RFEM and killing the process that runs my localhost as described here

During writing this comment I came to this idea. This allowed me to use the API after restarting RFEM.

Currently this works. For me this is not the most elegant solution.

Hope this helps other users and leads to a possible solution where no such quick-fixes are needed.

Kind regards

heetrojivadiya commented 2 months ago

Hey @JohannesSchorr,

I guess your issue was related to ports selection and their associated methods. Port 8081 is for the Application methods and port 8082 is for the Model methods which you may find in wiki of this repo. So, in your case you were getting active model with port 8081 which generally throws port 8082 and when rerunning code by changing port 8082 which is for model methods and in 8082, there is no such method like get_active_model() which is the cause of the error.

I hope this clarifies your issue.

JohannesSchorr commented 2 months ago

Hey @heetrojivadiya,

thanks for investing your time.

For clarification

Further Questions

Thanks again for the clarification. Allways happy to learn something new.

Kind regards