Board index FlightGear Support Interfacing

Multiple httpd server only first server accessible

Connecting two computers, using generic protocol, connecting with Matlab?

Multiple httpd server only first server accessible

Postby tldrc » Fri May 06, 2022 11:36 am

According to https://wiki.flightgear.org/Property_Tree_Servers
I should be able to set up multiple httpd server.

Some background of what I am trying to achieve.
I have 2 programs that is communicating through http to get value from the property tree

An example is doing a request for http://localhost:8081/json/orientation/pitch-deg

I notice that I cannot have 2 program reading from the same port, the second program would fail to connect so I figured opening a second server is the way to go.

The follow is my commandline settings
fgfs
--httpd=8081
--httpd=8082
--telnet=5001
--allow-nasal-from-sockets
--native-fdm=socket,out,60,192.168.1.4,4001,udp
--native-ctrls=socket,out,60,192.168.1.4,4002,udp

The problem I am having now is localhost:8082 does not serve anything.
If there is a better way to read the property tree at a high frequency please show.
Any help and suggestions would be appreciated. Thanks in advance.
tldrc
 
Posts: 19
Joined: Wed May 19, 2021 2:49 am

Re: Multiple httpd server only first server accessible

Postby tldrc » Fri May 06, 2022 12:12 pm

I found the proper way to specify multiple http server ports

fgfs httpd=8081,8082

edit: should be
fgfs --httpd=8081,8082

The wiki entry is very outdated.
Last edited by tldrc on Wed Jun 01, 2022 4:31 am, edited 1 time in total.
tldrc
 
Posts: 19
Joined: Wed May 19, 2021 2:49 am

Re: Multiple httpd server only first server accessible

Postby TheEagle » Fri May 06, 2022 5:20 pm

tldrc wrote in Fri May 06, 2022 12:12 pm:The wiki entry is very outdated.

Fixed ! :)
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3411
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Re: Multiple httpd server only first server accessible

Postby wkitty42 » Sat May 07, 2022 1:07 pm

tldrc wrote in Fri May 06, 2022 11:36 am:I notice that I cannot have 2 program reading from the same port, the second program would fail to connect so I figured opening a second server is the way to go.

i know you found the solution you were seeking... i'm glad you found it... i'm not sure about the above comment, though... i regularly have multiple browsers open looking at my one FG running on my gaming system... they're all connecting to the same server port and there's no problems... these multiple browsers may be on the same machine, different machines, or a combination of both... both my phone and tablet can watch my FG sessions as easily as my desktop systems...

i don't know what you are using to connect with but it should be noted, there are two ports to consider... your client apps have to attach to a local port so they can then link to the server's remote port for the connection... each of your client apps has to use a different local port but they can all link to the same server's remote port at the same time... so your client app might be using local port 23456 to talk to your FG's http server port 8080 or whatever... this local port is generally selected by the client app during startup and may be held onto for the entire session... some client apps will use a range of local ports and switch between them... some will use two or more at the same time...

anyway, if you start a 2nd instance of your client app, it cannot use local port 23456 because the 1st instance already owns it... so if you were seeing a 2nd instance of your client reporting it could not access a port, it was probably trying to use a local port that's already in use... if this is the case, figuring out how to have multiple instances of the client use different local ports is the solution... then they can all talk to the same remote server's port...
"You get more air close to the ground," said Angalo. "I read that in a book. You get lots of air low down, and not much when you go up."
"Why not?" said Gurder.
"Dunno. It's frightened of heights, I guess."
User avatar
wkitty42
 
Posts: 9146
Joined: Fri Feb 20, 2015 4:46 pm
Location: central NC, USA
Callsign: wk42
Version: git next
OS: Kubuntu 20.04

Re: Multiple httpd server only first server accessible

Postby tldrc » Wed May 18, 2022 4:17 am

Thanks TheEagle for updating the wiki.

Hi wkitty42,

Thanks for the reply. I understand what you are mean regarding the local/remote ports.
However, I believe my problem is caused by something else.

I am making async web request in csharp/Unity to get the properties.
The second client doing the query does not get result returned if the first client crosses a certain frequency of queries.
My current guess is that there is a certain load that flightgear OR my async threading code could handle before queries start failing to return results.
It is no longer a port issue. I will confirm again whether both can connect to the same port under light load (query frequency)
tldrc
 
Posts: 19
Joined: Wed May 19, 2021 2:49 am


Return to Interfacing

Who is online

Users browsing this forum: No registered users and 2 guests