Connection Manager


#1

Hello you all,

I have a project that runs on an FX30 Gateway, basically I have some python scripts that connects do a server and send some data. Now I am facing a problem, that I must allow the Internet connection interface according to a user preference in a file.

The way I am doing now is to use a python script that calls ‘cm’ commands to configure cellular network and ‘ifup’ and ‘ifdown’ to disable and enable ethernet.

When I run it on terminal it works just fine, but when I put it on legato framework it times work and times not.

I would like some opinion, if it is the best way for me to do this or there is a better way.

Thanks in advance!

Gustavo

Gustavo


#2

Doing some tests today, I realized that the problem maybe is related to DNS on legato, for example if I call a ping script outside legato directly on terminal it works, when I run it on legato application, it gives me ‘bad address’.

I put the resolv.conf in the file dependencies, but it didn’t solve the problem.

Have anyone faced something like this?

Thank you!

Gustavo


#3

Hi Gustavo,

Please try modify your app .adef file:

Option 1 run as non-sandbox, in that case it should run just like you start it from terminal.

sandboxed: false

Option 2 keep run as sandbox but add required networking feature

requires:
{
    file:
    {
        // needed for networking:
        /lib/libnss_compat.so.2 /lib/
        /lib/libnss_files.so.2 /lib/
        /lib/libnss_dns.so.2 /lib/
        /lib/libresolv.so.2 /lib/
        /etc/nsswitch.conf /etc/
        /etc/hosts /etc/
        /etc/resolv.conf /etc/
    }
}

Please refer to below for more info:
https://docs.legato.io/latest/defFilesAdef.html#defFilesAdef_sandboxed
https://github.com/legatoproject/legato-af/blob/master/apps/sample/httpGet/httpGet.adef

Hope it helps.
Thx


#4

Hi lotam,

Thanks for your suggestion, I tried both suggestion and both presented the same problem. I realized that when I am connected through the cellular network, when my script pings it returns it: "“ping: bad address ‘google.com’”, but when I am connected through the Ethernet network it works.

Have you any idea why this happens?

Thank you so much!

Gustavo


#5

Hi Gustavo,

Would you clarify what work and what not?

Using ethernet:

  • run script manaully on console
  • run App

Using cellular:

  • run script manaully on console
  • run App

Also, would you check content of /etc/resolv.conf after established cellular data connection?

cat /etc/resolv.conf

And try manually set a DNS and see does the script/app works:

echo “nameserver 8.8.8.8” > /etc/resolv.conf

Thx


#6

Hi lotam,

When I use ethernet, in both ways it works.

When I use cellular, just using script on console works.

The content of resolv.conf when the data connection is stablished is the following

nameserver 189.40.198.80
nameserver 189.40.198.81

nameserver 8.8.8.8

An additional thing that I did this weekend was to set the pdp just to IPV4, and now I am able to use “curl” to get a web page running the application.

Another thing that have a different behavior when used on console and in the application, is that when I connect to internet over cellular, I must disable the eth0 interface, when my script calls “ifdown eth0” on console, it works just fine, but in the legato application it does not. Any idea about it?

Thank you so much!

Gustavo


#7

Hi Gustavo,

Sorry for late.
As I don’t have FX30 and not sure the exact script/app you are testing, it is hard for me to check further why:

must disable the eth0 interface, when my script calls “ifdown eth0” on console, it works just fine, but in the legato application it does not.

I would guess it is

  • routing problem, maybe you can check Linux route (before/after “ifdown eth0”).
  • For app failed, does Legato app really able to down eth0? Do you set “sandboxed: false”?

Thx