No connection when using mavproxy with jsbsim

I am facing the problem that running the with the -f jsbsim option does not work. The problem has been described here:

According to the contributors, the issue should be fixed now. However, I am still facing the problem, despite of using the newest ardupilot code version.

Does anybody else have this problem? I would be very grateful for any help!

I just tried out the JSBSim simulation on my machine everything’s working properly. Closed it and again launched the simulation, still working

Are you using the latest JSBSim master? If not, please update it and try it again, there was a PR related to Ardupilot which was merged recently, that shouldn’t cause the problem but just in case.

Also, does the XTerm window show JSBSim starting correctly? There might be some error message about the connection from the JSBSim side also earlier


thank you for your super quick reply! I am using the latest version of the JSBSim master.

The XTerm window shows JSBSim starting correctly, I attached the XTerm output as a .txt file.

jsbsim_xterm.txt (12.1 KB)

In the terminal from which I started the I get the following error message:

Connect tcp: source_system=255
[Errno 111] Connection refused sleeping

The full command I used to start the simulation is: --map --console -f jsbsim --debug

Well, the Xterm output seems clean, doesn’t seem to be any problem from that side.

Are you running this on Ubuntu 16.04 or something else?
Is the default SITL working correctly?
Please check this, after you close the, check if the JSBSim process has been killed or not, you can use ps aux | grep JSBSim, there shouldn’t be anything else other than the grep process.

One last thing, wait for some 30secs to 1 min before again launching the simulation, the OS can take some time to free the ports. And also restart your system and try.

The main problem is that I’m not able to reproduce the error, that’s why need to do all this to see if anything can fix it

I am using Ubuntu 18.04.

The default SITL (i.e --map --console) works fine. The JSBSim process has been killed, I checked it with the provided command. Only the grep process appears then.

Also restarting the system did not work.

However, I noticed the following message in the xTerm output:

“Could not bind to socket for input …”

It does not appear in the same line each time I start the simulation, but it always appears. I think this is somehow the reason for the issue, some kind of connection problem between mavproxy and jsbsim…Also the terminal in which I started the script gives the output:

Waiting for heartbeat from tcp:

This is the problem, seems to be from the JSBSim side.
Is there any error message specifying the exact problem happening after this line?

You can also add the following code after this line, this will show any problem while connecting from the ardupilot side

Add this:

if (!sock_control.connect("!", control_port)) {
    printf("Error while connecting to socket at - Error: %s\n", 
                                             control_port, strerror(errno));
    return false;

Add it here also, change the variable name as needed

Sorry for all this, need to pinpoint the error. JSBSim works normally on 16.04, but might be that there are some problems on 18.04, if so then will need to create an issue on the JSBSim repo

Just had an idea, can try out Ardupilot with JSBSim in a 18.04 Docker container, not sure if it will work or not
Do post if you get some new info or were able to figure out what’s going on, if there’s any specific workaround required then it can be added to the Wiki

ArduPilot master and

commit 3dcfda17fef0e58d077fcb9b24ee2cb9b68d3a95 (HEAD, JSBSim-Team/master)

are working for me today.

Unfortunately, there is no error message on the ardupilot side, I just see mavroxy waiting for connection, indicated by the “MAV>” prompt.

There are also no further details in the error message. I also browsed the JSBSim source code I have on my machine and could not find the string “Could not bind to socket for input…” which is the error message I get from JSBSim. However, I found out, that this string was used in the file jsbsim/src/input_output/FGfdmSocket.cpp but was replaced in a commit from 10 Mar 2018 (see Is it possible that I am somehow running an old version of JSBSim? I went into the jsbsim directory and ran git log. It showed me that the last commits are from June 9, 2019 so I am really confused where this error message comes from…

Maybe this helps, I used sockstat to see on which ports the programs are communicating with each other:

arduplane 29979 udp4 *:5376 * : * CLOSED
arduplane 29979 udp4 ESTABLISHED
arduplane 29979 tcp4 ESTABLISHED
arduplane 29979 udp4 * : * CLOSED
arduplane 29979 tcp4 *:5632 * : * LISTEN
arduplane 29979 tcp4 ESTABLISHED
arduplane 29979 tcp4 *:5632 * : * LISTEN
arduplane 29979 tcp4 *:5632 * : * LISTEN
JSBSim 29982 tcp4 *:5376 * : * LISTEN

Hello there, I am still not sure what exactly the problem was, but I fixed it so I think it might be worth sharing. It is really a special case, but however maybe it might help.

I don’t know how that happened, but I somehow had an executable of JSBSim in my /usr/games/ directory. This directory was also in the PATH variable, before the ~/jsbsim directory. So every time JSBSim was executed it was the one in /usr/games/ which apparently did not wórk. After deleting this executable everything works fine now.


That worked for me too! Thanks a lot for sharing the fix :smiley:
Even so, after starting jsbsim and see the plane on the map, it is spinning around itself and I can’t figure it out why…
Correction: I was starting the simulator by " -v ArduPlane --console --map -f jsbsim:MyModel ", instead of “ -v ArduPlane -f jsbsim:Rascal --console --map”…
Everything is working now!