- the stream starts (I see it in the Wowza log and also in the StreamManager web interface)
- the VLC starts to play but it stops after 3-4 seconds
- if I press play button in VLC one more time, the video plays nicely in VLC without any problems
What should I do in order for the video to play properly in VLC from the first attempt? I guess there is some kind of delay I should implement somewhere. But I don't know where: server side (in some config files or in the code) or at the player (VLC) level.
I would suggest you sniff traffic out of VLC to understand why it fails. I guess it could be related to HLS design, which requires at least 3 chunks in the playlist. At the moment you create it, you won't have those chunks available (depending how long you have the chunks to be set, it's the time you'll have to wait)
Not all players process HLS the same. IPAD won't play if there's no 3 chunks in the list. VLC might start, but when request the manifest again, there's nothing new, so it stops.
Technically speaking, as HLS requires those 3 chunks per definition of a live stream, starting the stream on first connection will require more than just a delay, but a checking if the manifest received is good enough to start a live playback