Skip to main content



      Home
Home » Eclipse Projects » 4DIAC - Framework for Distributed Industrial Automation and Control » Client with http-server(Problems to get a communication between a http-server (python) and the client-fb)
Client with http-server [message #1866807] Thu, 06 June 2024 21:16 Go to next message
Eclipse UserFriend
Hello

I want to get and push parameters to a http-server . I build forte from source and activated http=on.
Sadly it's not actually working. My main problem is to set up the id right.
At the moment I only get NO_SOCKET or INVALID_ID as status
Can someone give me one example for get and one for push.
I'm also not sure if I have a bug.
Or are there another common mistakes.

In my test I just tried to read strings from the server.
Thank you all
Dustin

[Updated on: Thu, 06 June 2024 21:24] by Moderator

Re: Client with http-server [message #1866810 is a reply to message #1866807] Thu, 06 June 2024 21:18 Go to previous messageGo to next message
Eclipse UserFriend
Sry for that many topics I always get an error my bad.
Re: Client with http-server [message #1866813 is a reply to message #1866810] Thu, 06 June 2024 22:14 Go to previous messageGo to next message
Eclipse UserFriend
It's taken care of, Dustin.
Re: Client with http-server [message #1866816 is a reply to message #1866813] Fri, 07 June 2024 02:20 Go to previous messageGo to next message
Eclipse UserFriend
Did you take a look at https://eclipse.dev/4diac/en_help.php?helppage=html/communication/http.html for some examples? Can you share how are you setting the PARAMS and which Function Block are you using to get the string of the server?
Re: Client with http-server [message #1866822 is a reply to message #1866807] Fri, 07 June 2024 08:49 Go to previous messageGo to next message
Eclipse UserFriend
Could solve my problem with the GET-request
thank you.
I built my 4diac IDE again and created a new FB and now it works.
Helped me also: https://www.eclipse.org/forums/index.php/t/1109481/

[Updated on: Fri, 07 June 2024 10:40] by Moderator

Re: Client with http-server [message #1866825 is a reply to message #1866816] Fri, 07 June 2024 10:36 Go to previous messageGo to next message
Eclipse UserFriend
I could successfully build a get connection to a http-server.

But PUT or POST isn't working at the moment. My Server runs local (127.0.0.1) on PORT:9000 and I used on of the examples so that my ID is:

"http[127.0.0.1:9000/put;PUT;application/json]

I used from the Type Libary the Client_1 FB.

Thanks for the help
Dustin
Re: Client with http-server [message #1866828 is a reply to message #1866816] Fri, 07 June 2024 10:38 Go to previous messageGo to next message
Eclipse UserFriend
tried different IP-address so in my screenshot was the wrong one
I corrected the address back to 127.0.0.1 and the problem is still existing

[Updated on: Fri, 07 June 2024 10:47] by Moderator

Re: Client with http-server [message #1866831 is a reply to message #1866828] Sat, 08 June 2024 07:47 Go to previous messageGo to next message
Eclipse UserFriend
Do you get any error on forte? Probably the problem is because you have a RD in the client using POST/PUT. The documentation is wrong in that sense:

For a PUT/POST request you can set the data to be sent in two ways:
- On the PARAMETERS in the PARAM data input (see below)
- In a RD (exactly 1) of the client FB -----> This should be SD, and also should be clarified that no RD.
Re: Client with http-server [message #1866843 is a reply to message #1866831] Sat, 08 June 2024 22:50 Go to previous messageGo to next message
Eclipse UserFriend
I tried a configuration with and without RDs.
My Forte shows like in the .png that every client needs two RDs.

When I stop the program I get the error that the string to insert was empty.

I don't understand my mistake.

Thanks for your help and tips
Re: Client with http-server [message #1866852 is a reply to message #1866843] Sun, 09 June 2024 05:12 Go to previous messageGo to next message
Eclipse UserFriend
From the 4diac FORTE output I assume that you are using the develop branch for 4diac FORTE. AFAIR Monika did some improvements on the HTTP layer for that. She also updated and fixed the documentation. The new documentation can be found here: https://github.com/eclipse-4diac/4diac-documentation/blob/main/src/communication/http.adoc

This new documentation is also already part of the 4diac IDE documentation. However not yet on the web page. The reason for that is that we are currently reworking the web-page and changing the documentation on the old on is not really worth it.

PS: We are always happy for any support on improving our documentation.
Re: Client with http-server [message #1866933 is a reply to message #1866852] Tue, 11 June 2024 01:25 Go to previous messageGo to next message
Eclipse UserFriend
I used now the develop version of forte. I also created a client_3_2 (3SD and 2RD). I was able to create a GET-communication with my server.
But the POST and PUT-requests doesn't work at the moment.
I created a Server who accepts all types of requests GET/POST/PUT. It worked if I did a curl request.

POST-request: curl -X POST http://localhost:8000/daten -H "Content-Type: application/json" -d "{\"name\": \"John\", \"alter\": 30, \"verheiratet\": true, \"haustiere\": [\"Hund\", \"Katze\"]}"


PUT-request: curl -X PUT http://localhost:8000/daten -H "Content-Type: application/json" -d "{\"name\": \"John\", \"alter\": 30, \"verheiratet\": false, \"haustiere\": [\"Hamster\"]}"

My main issue is that the json-data not correctly arrives. Some data is arriving certified trough the line: Empfangene Daten erhalten -b' '
But not the right one.

I can't copy my curl -body (json-string) directly because I would need double qoutes around my wstring-body, but every double quotes around e.g. "name" causes an issue.
With single quotes and backslashes I'm getting the same result.

I added in the files my used python http-server, my post & put request and my client configuration.


Thanks for your help
Dustin
Re: Client with http-server [message #1866945 is a reply to message #1866933] Tue, 11 June 2024 05:37 Go to previous messageGo to next message
Eclipse UserFriend
Not sure if this helps but the escape character for IEC 61131-3 Strings and WStrings is the $ instead of the \. So if you need to escape double quotes you need to use $" in 4diac IDE.
Re: Client with http-server [message #1866963 is a reply to message #1866945] Tue, 11 June 2024 05:53 Go to previous messageGo to next message
Eclipse UserFriend
not sure if it helps, but the inputs of this fb are of type ANY and i think you should add a type e.g. STRING#'' for all empty inputs, and STRING#'my text' for your input with content as well as WSTRING#"my ID"
Re: Client with http-server [message #1866999 is a reply to message #1866963] Tue, 11 June 2024 17:29 Go to previous messageGo to next message
Eclipse UserFriend
Thanks for all of you help!
Monikas last tip solved my problem from the former message.
I add two screenshots and my http-server here so I can get involved in the documentation or if someone else have the same problems.
Re: Client with http-server [message #1867023 is a reply to message #1866999] Wed, 12 June 2024 09:47 Go to previous messageGo to next message
Eclipse UserFriend
Thx for the feedback. If you have ideas how the documentation can be improved feel free to change it and submit a pull request. The great advantage of our new AsciDoc format and github is that you can directly edit the file on github and contribute your suggestion as PR.
Re: Client with http-server [message #1867029 is a reply to message #1867023] Wed, 12 June 2024 09:58 Go to previous messageGo to next message
Eclipse UserFriend
I will do. I have a hard schedule in the next two weeks. But after this I will add my learnings to the Dokumentation.
Re: Client with http-server [message #1867035 is a reply to message #1867029] Wed, 12 June 2024 10:06 Go to previous message
Eclipse UserFriend
This would be great. In the mean time all the best for your hard schedule.
Previous Topic:Algorithms on the develop branch
Next Topic:Incorrect communication between 4diac IDE and FORTE on Raspberry
Goto Forum:
  


Current Time: Tue Jun 17 04:45:02 EDT 2025

Powered by FUDForum. Page generated in 0.49003 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top