Error on socket: connection refused

Hello,

I have been trying to connect apm planner 2 to my arducopter (2.6) board over a TCP connection while using a VPN. The apm planner and the arducopter board are on different networks since the project i’m trying to do envolves long range communication over a cellular network.
My problem is that when I am on apm planner’s interface and try to add a TCP link (in the communication bar) I get the following error: “Error on socket: connection refused”. I somehow managed to connect them both the first time and was also getting telemetry data from the board but since then that error prevents me from doing so again. I have been reading online about this error (error #10061) but still can’t figure what’s wrong. I fear that the TCP port that I’m entering might be wrong, since the host address (IP address) is most certainly correct.

I’d be very grateful if someone could give me some feedback on how to find out which port to use and how to find it (I’m using Linux by the way).

Thanks!

I have managed to solve my problem.

I did not need to use a TCP connection after all…I used the usbip service. I will show you what commands i used in the process.

On the client PC (where the arducopter is connected):

$sudo usbipd -D
$modprobe usbip -core
$modprobe usbip -host
$modprobe usbip -vhci-hdc
$usbip list -l (this is optional, here the terminal should show you which bus ID the board is connected to, something like 1-1.4)
$usbip bind -b 1-1.4 (or whatever bus ID you need, not necessarily 1-1.4. This command will allow the bus ID to be used by other PCs)

This part of the process should now be complete!

Now on the VPN server PC:

$sudo modprobe vhci-hcd (this will allow virtual IDs to be "imported from other machines)
$sudo usbip list -r “IP address of the client” (this command should now show you the devices that are connected to your client PC)
$sudo usbip attach -r “IP address of the client” (the device you want should now be “virtually attached” to the server PC, you can go ahead and run APM Planner and connect to the board without a problem)

To detach from the server PC simply run:

$sudo usbip detach -p 00 -r “IP address of client” -b 1-1.4 (the port might not be 00, and again, the bus ID might not be 1-1.4)

Now, if you want to unbid, run the following command on the client PC:

$usbip unbind -b 1-1.4