Mender-connect unable to connect to server

Hi all,

I have successfully added mender-client to my custom board based on Raspberry CM4 using Yocto.
Here is my mender version :

meta-mender$ git log -1
commit 81cf8b81b0505dcb98872c21a8fce330a8ba28b6 (HEAD, tag: kirkstone-v2023.12)
Merge: cf7a4cec 5e9caf20
Author: Fabio Tranchitella <fabio.tranchitella@northern.tech>
Date:   Sun Dec 31 20:33:00 2023 +0000

    Merge pull request #2044 from tranchitella/kirkstone
    
    fix: license checksum for mender-gateway 1.2.0

Here is my layer conf:

$ cat local.conf | grep MENDER
MENDER_UPDATE_POLL_INTERVAL_SECONDS = ''                   
MENDER_INVENTORY_POLL_INTERVAL_SECONDS = ''                
MENDER_RETRY_POLL_INTERVAL_SECONDS = ''                    
MENDER_SERVER_URL = ''                                     
MENDER_TENANT_TOKEN = ''                                   
MENDER_EFI_LOADER = 'u-boot'                               
MENDER_ARTIFACT_NAME = 'mender-poc-1'                      
MENDER_STORAGE_DEVICE = '/dev/mmcblk0'                     
MENDER_STORAGE_TOTAL_SIZE_MB = '7456'                      
MENDER_BOOT_PART     = '${MENDER_STORAGE_DEVICE}p1'            
MENDER_BOOT_PART_SIZE_MB = '128'                               
MENDER_ROOTFS_PART_A = '${MENDER_STORAGE_DEVICE}p2'            
MENDER_ROOTFS_PART_B = '${MENDER_STORAGE_DEVICE}p3'            
MENDER_DATA_PART     = '${MENDER_STORAGE_DEVICE}p4'            
MENDER_DATA_PART_SIZE_MB = '2048'                              
MENDER_FEATURES_ENABLE:append = ' mender-image  mender-uboot mender-client-install'            
MENDER_FEATURES_DISABLE:append = ' mender-grub mender-image-uefi mender-image-sd' 
MENDER_ARTIFACT_NAME ='${BOX_DISTRIB_CODENAME}-${BOX_SW_VERSION}'

The mender-client is well connected to the server :

Here is conf files

cat /etc/mender/mender-connect.conf 
{
    "ReconnectIntervalSeconds": 5,
    "Limits": {
        "Enabled": true,
        "FileTransfer": {
            "Chroot": "/var/lib/mender/filetransfer",
            "OwnerGet": [
                "mender",
                "root"
            ],
            "GroupGet": [
                "games",
                "users"
            ],
            "OwnerPut": "root",
            "GroupPut": "mender",
            "MaxFileSize": 4,
            "FollowSymLinks": true,
            "AllowOverwrite": true,
            "RegularFilesOnly": true,
            "PreserveOwner": true,
            "PreserveGroup": true,
            "PreserveMode": true,
            "Umask": "",
            "Counters": {
                "MaxBytesTxPerMinute": 1048576,
                "MaxBytesRxPerMinute": 1048576
            }
        }
    },
    "FileTransfer": {
        "Disable": false
    },
    "MenderClient": {
        "Disable": false
    },
    "PortForward": {
        "Disable": false
    },
    "ShellCommand": "/bin/sh",
    "ShellArguments": [
        "--login"
    ],
    "Sessions": {
        "ExpireAfter": 0,
        "ExpireAfterIdle": 0,
        "MaxPerUser": 1,
        "StopExpired": false
    },
    "Terminal": {
        "Disable": false,
        "Height": 40,
        "Width": 80
    },
    "User": "root"
}

# cat /etc/mender/mender.conf 
{
    "ClientProtocol": "https",
    "ArtifactVerifyKey": "/etc/mender/artifact-verify-key.pem",
    "DeviceTypeFile": "/etc/mender/device_type",
    "UpdatePollIntervalSeconds": 5,
    "InventoryPollIntervalSeconds": 5,
    "RetryPollIntervalSeconds": 5,
    "StateScriptTimeoutSeconds": 0,
    "StateScriptRetryTimeoutSeconds": 0,
    "StateScriptRetryIntervalSeconds": 0,
    "ModuleTimeoutSeconds": 0,
    "UpdateLogPath": "",
    "TenantToken": "",
    "SkipVerify": false,
    "ServerURL": "https://mender.staging.xxxxx.fr/"
}



Here is the output :

# mender-connect -c /etc/mender/mender-connect.conf daemon
INFO[2024-01-26T09:44:33+01:00] Loaded configuration file: /etc/mender/mender-connect.conf 
ERRO[2024-01-26T09:44:43+01:00] connection manager failed to connect to http://127.0.0.1:40365/api/devices/v1/deviceconnect/connect: websocket: bad handshake; reconnecting in 5s (try 1/10); len(token)=826 
ERRO[2024-01-26T09:44:48+01:00] connection manager failed to connect to http://127.0.0.1:40365/api/devices/v1/deviceconnect/connect: websocket: bad handshake; reconnecting in 5s (try 2/10); len(token)=826 

Here is dbus check:

# dbus-send --system --dest=io.mender.AuthenticationManager --print-reply /io/mender/AuthenticationManager io.mender.Authentication1.GetJwtToken
method return time=1706259026.622384 sender=:1.10 -> destination=:1.19 serial=27 reply_serial=2
   string "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJmZWM1NDllNy0xMWJhLTRiMDYtYjc4OS0zMDEwMjU2ZTM2ZjgiLCJzdWIiOiI0NDliZmUwMC00ZjA1LTQyYzEtOWFhYy1kY2Y0NTMyYmI5YzMiLCJpc3MiOiJNZW5kZXIiLCJleHAiOjE3MDY4NjE3NjIsImlhdCI6MTcwNjI1Njk2MiwibmJmIjotNjIxMzU1OTY4MDAsIm1lbmRlci5kZXZpY2UiOnRydWUsIm1lbmRlci5wbGFuIjoiZW50ZXJwcmlzZSJ9.OaojUJM9h2Q5UkO3MjJ3R_ciInPWkXYeG-tkRGeC5D3QWZuyLuUN9BKf97nCkaqmEP6BQXWkM8UsFxD-BforAMVI73-sWD6g_Wi7OML-HNU-qaWtiIH3vDxEO5Llg31vyCUWQUrso65MoRwM6CWXmG2MprpFM3bt67kCKeg8FPkSW9elvz6Au6XfIpvo3b42fu0-aqxzOttsgXvVfe20Sd7F_f0EtzwXuXUsFkOnnEB2_mSI8GdavxEHZxg9wxrOPJREYeQ9gNaVfAOG9g8HjZxmYajWrv9oYa1fsQaWlF3XWLfGjmO__T_l0fgJEiGx5d5S-yB7Fd_vUIzlim7tv-d_26jVjBOYXgQE9mTdrwh5D97bWwjHsLrKbulMjhmUZajOLlA0P_gufpyZhpBQTNCZH3qxDvq4tqkfS6WzkK6n7QbVrtoM4IDStMxLFOEgt-yzBCSIu5DtN6ig01PqKR43INh4ZoYXXXXXXXXXXXXXX"
   string "http://127.0.0.1:40365"

I think the issue is the server url, which NOT should be localhost => http://127.0.0.1:40365
I think it should be : https://mender.staging.xxxxx.fr:40365

Any idea to solve this issue ?

Regards

Hi @LalunePierr0t,

mender-connect uses the so-called mender-auth component which is built into the Go-based client and shipped as a separated binary for the new C+±client. Hence, connecting to localhost:xxxxx is correct, and obtaining the exact port via d-bus is also right.

The ServerURL in /etc/mender/mender-connect.conf has been deprecated some time ago and is not honoured.

From a first glance I can’t tell where things are going wrong. Does it work if you connect the device to a managed Mender instance, such as https://hosted.mender.io?

Greetz,
Josef

Hi Josef,

It works perfectly, so it is a server issue. I ll see with IT.
Thanks for your time.

Regards

# mender-connect -c /etc/mender/mender-connect.conf daemon
INFO[2024-01-26T10:23:12+01:00] Loaded configuration file: /etc/mender/mender-connect.conf 
INFO[2024-01-26T10:23:22+01:00] eventLoop: Connection established with http://127.0.0.1:44267 
INFO[2024-01-26T10:24:52+01:00] mender-connect starting shell command passing process, pid: 66006