What could change this behavior? I see that the first 404 I get return is passed on.

Could it be the t_newtran(). I Honestly don't remember why we put it there.
if ( !lookup("doorlocation") ) {
                $var(rc) = $rc;
                t_newtran();
                switch ($var(rc)) {


The doorlocation is also a "fake" location table, not used for registrations, but to make a branch to either a fixed terminal, or a mobile phone, which uses a second location table. 
The fixed terminal can right away return 404, but the mobile phone, first has to receive a push, which can take some seconds.
Can this time difference in reply cause the issue?

  Kjeld Flarup

2018-04-16 9:23 GMT+02:00 Daniel-Constantin Mierla <miconda@gmail.com>:
Hello,

you do not need to discard the branch replies at all. Kamailio sends
only one reply back, even if you do many outgoing branches, kamailio is
going to wait until all of the get a final reply and then selects the
one with highest priority to send back.

Cheers,
Daniel


On 14.04.18 23:05, Kjeld Flarup wrote:
> Hello
>
> What is the correct way to handle, if a branched call reaches a 404 on
> one of the branches.
>
> Currently I discard all 404 in onreply_route, but if all branches has
> 404, then this is never send to the caller.
>

--
Daniel-Constantin Mierla
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio Advanced Training - April 16-18, 2018, Berlin - www.asipto.com
Kamailio World Conference - May 14-16, 2018 - www.kamailioworld.com