Assertion "a->len <= a->size" when sending udp

Hello, I am trying to send udp packet from mongoose os on olimex esp32, but failing with coredump and I can’t see the reason.

Minimalized code is here: https://pastebin.com/tnXLLTS3

Application fails with:

[Apr 14 12:37:20.327] mgos_net.c:102 ETH: ready, IP 192.168.17.114, GW 192.168.17.1, DNS 192.168.17.1
[Apr 14 12:37:20.335] main.cpp:36 Net got IP address
[Apr 14 12:37:20.338] mgos_event.c:135 ev NET3 triggered 2 handlers
[Apr 14 12:37:23.341] main.cpp:12 sending 0
[Apr 14 12:37:23.344] mongoose.c:3145 0x3ffcc72c udp://192.168.17.30:7777 -,-,-
[Apr 14 12:37:23.349] mongoose.c:3013 0x3ffcc72c udp://192.168.17.30:7777
[Apr 14 12:37:23.356] main.cpp:17 sent 1
[Apr 14 12:37:23.356] mongoose.c:3028 0x3ffcc72c udp://192.168.17.30:7777 -> 0
[Apr 14 12:37:23.366] mgos_mongoose.c:66 New heap free LWM: 206888
[Apr 14 12:37:26.341] main.cpp:12 sending 1
[Apr 14 12:37:26.344] assertion “a->len <= a->size” failed: file “/data/tmp/mos_prebuild/tmp/cesanta/mos-libs/mongoose/src/mongoose.c”, line 1458, function: mbuf_insert
[Apr 14 12:37:26.355] abort() was called at PC 0x40104b4b on core 1

What am i doing wrong? I tried to use the same connection, create new connection for every packet, always the same result.

Thank you

Found reason myself - socket wasn’t initialized.

Here is working sample code: https://pastebin.com/dhbnRX8t

(… and this is why I really hate hate hate programming in C)