Hi Steve
I have two demo programs, and both work well.
I can set up a PC Web server, and I can use the Web App to retrieve text from the matrix server, which works
But when I try to retrieve text with the Web App from the my web server (localhost), it doesn't work yet.
How to connect PC App and Web App together
-
stefan.erni
- Valued Contributor
- Posts: 1250
- http://meble-kuchenne.info.pl
- Joined: Wed Dec 02, 2020 10:53 am
- Has thanked: 231 times
- Been thanked: 248 times
-
Steve-Matrix
- Matrix Staff
- Posts: 1934
- Joined: Sat Dec 05, 2020 10:32 am
- Has thanked: 288 times
- Been thanked: 451 times
Re: How to connect PC App and Web App together
I've edited your files to show how this could happen.
Some changes I made to the Web Developer app:
You can test to see if the PC Developer web server is active by opening page the following in a browser:
It should report the JSON string.
The IP address is likely to be different and is the one specified by the Network Comms IP Address property.
Here are some images showing it working:
Some changes I made to the Web Developer app:
- The DataType is now JSON Encoded
- The URL is a local IP address as created by the PC Developer app's Network Comms IP Address
- The ProcessResponse macro extracts the "Data" tag from the received JSON packet
- Removed the File I/O component
- Changed the HTML source to Embedded
- Added a custom header for CORS and JSON
- Added the "fetchtest.txt" file with a JSON string
You can test to see if the PC Developer web server is active by opening page the following in a browser:
Code: Select all
http://192.168.0.90/fetchtest.txtThe IP address is likely to be different and is the one specified by the Network Comms IP Address property.
Here are some images showing it working:
- Attachments
-
- WebFetchHTML_ST.fcweb
- (11.31 KiB) Downloaded 28 times
-
- Webserver_FileSystem_ST.fcpcd
- (14.33 KiB) Downloaded 27 times
-
stefan.erni
- Valued Contributor
- Posts: 1250
- Joined: Wed Dec 02, 2020 10:53 am
- Has thanked: 231 times
- Been thanked: 248 times
Re: How to connect PC App and Web App together
Hi Steve
Perfect!
I can use “localhost” instead of the IP address, so I won't have to make any adjustments if it runs on a different computer And the result from the Web App:
So, connecting the Web App to the PC App is very easy and user-friendly.
One more question:
Do I always have to do pooling from the Web App, or can I also send data from the PC App?
Perfect!
I can use “localhost” instead of the IP address, so I won't have to make any adjustments if it runs on a different computer And the result from the Web App:
So, connecting the Web App to the PC App is very easy and user-friendly.
One more question:
Do I always have to do pooling from the Web App, or can I also send data from the PC App?
-
Steve-Matrix
- Matrix Staff
- Posts: 1934
- Joined: Sat Dec 05, 2020 10:32 am
- Has thanked: 288 times
- Been thanked: 451 times
Re: How to connect PC App and Web App together
I think polling if how I'd do it. If you want the Web app to respond to incoming data without polling, then you could look at using MQTT as a way of routing messages between the PC app and the Web app.
-
stefan.erni
- Valued Contributor
- Posts: 1250
- Joined: Wed Dec 02, 2020 10:53 am
- Has thanked: 231 times
- Been thanked: 248 times
Re: How to connect PC App and Web App together
Hi Steve
With your example, polling every 500 milliseconds works very well.
I can simply use a button in the PC-App to set a state (Ledon on/off) in the Web App
With your example, polling every 500 milliseconds works very well.
I can simply use a button in the PC-App to set a state (Ledon on/off) in the Web App
- Attachments
-
- WebFetchHTML_ST2.fcweb
- (12.83 KiB) Downloaded 4 times
-
- Webserver_FileSystem_ST2.fcpcd
- (19.25 KiB) Downloaded 4 times