Thank you, Sebkinne, this worked, i made an error in building the context stream.
But i see you're also using file_get_contents, instead of cURL. I prefer to use cURL because it is a little faster. The script isn't doing much most of the time. It sends real time log entries to another system, the receiver does not accept multiple entries. Especially when starting, it could burst >100 entries instantly, therefore the processing time is more or less relevant.
Anyway, working fine now; thanks!