require websocket and https combine example

Hi,

I am using SDK v2.6.1.

Is there any course available on DevAcademy for WebSockets?

For WebSocket i take reference of v2.6.1/zephyr/samples/net/sockets/websocket_client,

when i try to give wifi credential using wifi connect -s <ssid> -k 1 -p <password> then i have got wifi: command not found so require to give wifi credential?or how we are able to see WebSocket reference code output,

I need an example that merges WebSocket and HTTPS. Could you also provide feedback on how to merge both into a single code?

  • Hi,

    please try with attached code.

    Also please give me code which work with websocket so first i will take a reference of it and try to merge with https.

    sta_websocket.zip

  • Hi,

    I have tested further your previous project HTTP.zip. There seems to be connection consistently. The change was to extend the sleep to allow for initialization of the wi-fi driver using k_sleep(K_SECONDS(10)); instead of k_sleep(K_SECONDS(1));

    [00:00:00.502,746] <inf> fs_nvs: 2 Sectors of 4096 bytes
    [00:00:00.502,746] <inf> fs_nvs: alloc wra: 0, fd0
    [00:00:00.502,777] <inf> fs_nvs: data wra: 0, c8
    *** Booting nRF Connect SDK v3.5.99-ncs1-1 ***
    [00:00:02.055,969] <inf> wifi_mgmt_ext: Connection requested
    [00:00:02.056,732] <inf> Lesson5_Exercise1: Connecting to Wi-Fi
    [00:00:04.606,048] <inf> wifi_mgmt_ext: Connection requested
    [00:00:07.159,393] <inf> wifi_mgmt_ext: Connection requested
    [00:00:09.713,409] <inf> wifi_mgmt_ext: Connection requested
    [00:00:12.267,883] <inf> wifi_mgmt_ext: Connection requested
    [00:00:14.834,533] <inf> wifi_mgmt_ext: Connection requested
    [00:00:17.400,695] <inf> wifi_mgmt_ext: Connection requested
    [00:00:19.947,631] <inf> wifi_mgmt_ext: Connection requested
    [00:00:22.501,220] <inf> wifi_mgmt_ext: Connection requested
    [00:00:25.055,206] <inf> wifi_mgmt_ext: Connection requested
    [00:00:27.609,893] <inf> wifi_mgmt_ext: Connection requested
    [00:00:30.181,518] <inf> wifi_mgmt_ext: Connection requested
    [00:00:30.264,404] <inf> Lesson5_Exercise1: Network connected
    [00:00:32.203,094] <inf> Lesson5_Exercise1: IPv4 address of HTTP server found 54.240.174.114
    [00:00:33.456,909] <inf> Lesson5_Exercise1: Connected to server
    [00:00:33.456,939] <inf> Lesson5_Exercise1: HTTP POST request
    [00:00:33.571,350] <inf> Lesson5_Exercise1: Response status: Created
    [00:00:33.571,380] <inf> Lesson5_Exercise1: Successfully acquired client ID: /fb269045-2f73-4068-8064-b227e8a6cf70
    [00:00:33.571,411] <inf> Lesson5_Exercise1: Closing socket: 9
    [00:00:36.434,722] <err> Lesson5_Exercise1: Cannot connect to IPv4 remote (-116)
    [00:00:36.435,150] <err> Lesson5_Exercise1: Cannot connect to echo.thingy.rocks:80
    [00:00:36.435,241] <err> Lesson5_Exercise1: No IPv4 or IPv6 connectivity
    

    I have also tested your most recent sample project sta_websocket.zip. Here is my log

    [00:00:41.839,843] <inf> sta: IPv4 address of HTTP server found 143.204.55.79
    [00:00:42.560,241] <inf> sta: Connected to server
    [00:00:42.560,241] <inf> sta: HTTP POST request
    [00:00:42.652,740] <inf> sta: Response status: Forbidden
    [00:00:42.652,801] <inf> sta: Successfully acquired client ID: /<!DOCTYPE HTML PUBLIC "-//W3C//DTD H
    [00:00:42.652,801] <inf> sta: Closing socket: 9
    [00:00:44.725,738] <err> sta: Cannot connect to IPv4 remote (-116)
    [00:00:44.726,165] <err> sta: Cannot connect to demos.kaazing.com:80
    [00:00:44.726,257] <err> sta: No IPv4 or IPv6 connectivity

    Do you get the same log?

    Best regards,
    Dejan

  • yes i have got the same log, i am also not able to connect with the the websocket so i have got 

    [00:00:44.725,738] <err> sta: Cannot connect to IPv4 remote (-116)
    [00:00:44.726,165] <err> sta: Cannot connect to demos.kaazing.com:80
    [00:00:44.726,257] <err> sta: No IPv4 or IPv6 connectivity

  • Hi,

    We will look into this internally. I expect to get back to you by the end of next week.

    Best regards,
    Dejan

  • ok,

    Thank you for your support.

    If possible, please expedite the process as we have an upcoming client delivery.

Related