golioth / golioth-zephyr-sdk

Golioth SDK For Zephyr
https://www.golioth.io
Apache License 2.0
68 stars 19 forks source link

[Bug]: Failed to connect (-95) on NCS 1.8.0 #157

Closed TjazVracko closed 2 years ago

TjazVracko commented 2 years ago

Hardware Target

nrf9160dk_nrf9160_ns

Golioth Dsdk Commit Hash

440b700ef90f47bfaf37916d4f2e670416859419

What Host OS are you using?

Ubuntu

What happened?

I am evaluating using Golioth for my company for one of our projects that is on NCS 1.8.0

I tried both the samples provided in the Golioth SDK and making my own test sample:

void main(void)
{
    int counter = 0;
    int err;

    LOG_DBG("Start Logging sample");

    err = lte_lc_init_and_connect_async(lte_handler);
    if (err)
    {
        printk("lte_lc_init_and_connect_async, error: %d\n", err);
        return;
    }

    k_sem_take(&lte_connected, K_FOREVER);

    client->on_message = golioth_on_message;
    golioth_system_client_start();

    while (true)
    {
        LOG_INF("INFO: the counter is %d", counter);

        counter++;

        k_sleep(K_SECONDS(5));
    }
}

On NCS 1.7.1 this works as intended -> The logs reach your servers On NCS 1.8.0 this does not work, a Failed to connect: -95 is reported.

Is this a known issue? Are there any configuration changes required to make this work?

Regards, Tjaž

Relevant log output

On NCS 1.7.1

uart:~$ *** Booting Zephyr OS build v2.6.99-ncs1-1  ***
[00:00:00.209,167] <inf> golioth_system: Initializing
[00:00:00.209,472] <dbg> main.main: Start Logging sample
uart:~$ Connected to: home network
[00:00:02.420,623] <inf> main: INFO: the counter is 0
[00:00:02.420,745] <inf> golioth_system: Starting connect
[00:00:02.512,390] <inf> golioth_system: Client connected!
[00:00:07.420,715] <inf> main: INFO: the counter is 1
[00:00:12.420,806] <inf> main: INFO: the counter is 2
[00:00:17.420,928] <inf> main: INFO: the counter is 3
[00:00:22.421,020] <inf> main: INFO: the counter is 4
...

--------------------------------------------------------
On NCS 1.8.0

uart:~$ *** Booting Zephyr OS build v2.7.0-ncs1  ***
[00:00:00.208,129] <inf> golioth_system: Initializing
[00:00:00.208,526] <dbg> main.main: Start Logging sample
uart:~$ Connected to: home network
[00:00:04.649,475] <inf> main: INFO: the counter is 0
[00:00:04.649,597] <inf> golioth_system: Starting connect
[00:00:05.043,823] <err> golioth_system: Failed to connect: -95
[00:00:05.043,823] <wrn> golioth_system: Failed to connect: -95
[00:00:09.649,627] <inf> main: INFO: the counter is 1
[00:00:10.043,945] <inf> golioth_system: Starting connect
[00:00:13.044,189] <err> golioth_system: Failed to connect: -95
[00:00:13.044,219] <wrn> golioth_system: Failed to connect: -95
[00:00:14.649,719] <inf> main: INFO: the counter is 2
[00:00:18.044,281] <inf> golioth_system: Starting connect
[00:00:19.649,810] <inf> main: INFO: the counter is 3
...

Code of Conduct

vitprajzler commented 2 years ago

Thanks for reporting this @comemaster, the root cause is broken native sockets in NCS 1.8.0 (duplicates #158). It's not Golioth specific, it has to be fixed in NCS. In the meantime, I recommend using NCS 1.7.1, which is what we released our SDK against.